// package com.zmn.oms.task.es.business.impl.orderwork;
//
// import com.alibaba.fastjson.JSON;
// import com.google.common.collect.Lists;
// import com.google.common.collect.Maps;
// import com.google.common.collect.Sets;
// import com.zmn.common.constant.FicoConsts;
// import com.zmn.common.constant.GlobalConsts;
// import com.zmn.common.dto2.ResponseDTO;
// import com.zmn.common.utils.collection.CollectionUtil;
// import com.zmn.common.utils.date.DateUtil;
// import com.zmn.common.utils.number.NumberUtil;
// import com.zmn.common.utils.reflect.BeanMapper;
// import com.zmn.common.utils.string.StringUtil;
// import com.zmn.engineer.common.dto.engineer.BaseEngineerDRO;
// import com.zmn.engineer.dubbo.interfaces.engineer.EngineerListRemoteService;
// import com.zmn.erp.common.newbiz.constrants.invoicemanage.InvoiceInfoConstant;
// import com.zmn.erp.common.newbiz.dro.invoicemanage.InvoiceInfoDRO;
// import com.zmn.erp.common.newbiz.dro.oms.AccountDetailDRO;
// import com.zmn.erp.dubbo.interfaces.newbiz.account.AccountDetailListRemoteService;
// import com.zmn.erp.dubbo.interfaces.newbiz.invoicemanage.InvoiceInfoListRemoteService;
// import com.zmn.erp.dubbo.utils.DubboConsts;
// import com.zmn.manager.mq.constant.MqTagConsts;
// import com.zmn.manager.mq.constant.MqTopicConsts;
// import com.zmn.manager.mq.interfaces.ZmnMQSender;
// import com.zmn.oms.business.interfaces.servtype.ServItemBService;
// import com.zmn.oms.business.interfaces.tmall.OrderTmallExtendBService;
// import com.zmn.oms.business.interfaces.work.OrderWorkListBService;
// import com.zmn.oms.business.interfaces.worktrack.WorkTrackBService;
// import com.zmn.oms.common.constant.*;
// import com.zmn.oms.common.dto.MapDTO;
// import com.zmn.oms.model.entity.acceptance.OrderWorkAcceptance;
// import com.zmn.oms.model.entity.changerecord.OrderChangeRecord;
// import com.zmn.oms.model.entity.comment.OrderComment;
// import com.zmn.oms.model.entity.comment.OrderCommentDetail;
// import com.zmn.oms.model.entity.discount.OrderDiscount;
// import com.zmn.oms.model.entity.enterpriseWeChat.EnterpriseWeChatLog;
// import com.zmn.oms.model.entity.factory.OrderFactory;
// import com.zmn.oms.model.entity.fcorderpart.OrderFactoryPart;
// import com.zmn.oms.model.entity.fcorderpart.OrderFactoryPartPost;
// import com.zmn.oms.model.entity.master.OrderMaster;
// import com.zmn.oms.model.entity.member.OrderMember;
// import com.zmn.oms.model.entity.nonstandard.OrderNonstandard;
// import com.zmn.oms.model.entity.omstrack.OrderWorkTrack;
// import com.zmn.oms.model.entity.operation.OrderOperation;
// import com.zmn.oms.model.entity.order.OrderExtend;
// import com.zmn.oms.model.entity.orderattachment.OrderAttachment;
// import com.zmn.oms.model.entity.pay.OrderPay;
// import com.zmn.oms.model.entity.post.OrderPost;
// import com.zmn.oms.model.entity.product.OrderProduct;
// import com.zmn.oms.model.entity.refund.OrderWorkRefundDetail;
// import com.zmn.oms.model.entity.remark.OrderRemark;
// import com.zmn.oms.model.entity.remark.OrderRemarkDetail;
// import com.zmn.oms.model.entity.review.OmsOrderReview;
// import com.zmn.oms.model.entity.serviceitem.OrderServiceItem;
// import com.zmn.oms.model.entity.shop.OrderShop;
// import com.zmn.oms.model.entity.statement.OrderStatement;
// import com.zmn.oms.model.entity.tag.OrderTag;
// import com.zmn.oms.model.entity.tamllextend.OrderTmallExtend;
// import com.zmn.oms.model.entity.track.OrderTrack;
// import com.zmn.oms.model.entity.visit.OrderVisit;
// import com.zmn.oms.model.entity.warranty.OrderWarranty;
// import com.zmn.oms.model.entity.warranty.OrderWarrantyProduct;
// import com.zmn.oms.model.entity.work.OrderWork;
// import com.zmn.oms.model.entity.work.OrderWorkQuery;
// import com.zmn.oms.model.es.*;
// import com.zmn.oms.model.vo.order.EsOrderDetailVO;
// import com.zmn.oms.services.interfaces.acceptance.OrderWorkAcceptanceService;
// import com.zmn.oms.services.interfaces.changerecord.OrderChangeRecordService;
// import com.zmn.oms.services.interfaces.comment.OrderCommentService;
// import com.zmn.oms.services.interfaces.detail.OrderDetailService;
// import com.zmn.oms.services.interfaces.discount.OrderDiscountService;
// import com.zmn.oms.services.interfaces.enterpriseWeChat.EnterpriseWeChatService;
// import com.zmn.oms.services.interfaces.express.OrderPostService;
// import com.zmn.oms.services.interfaces.factory.OrderFactoryService;
// import com.zmn.oms.services.interfaces.fcorderpart.OrderFactoryPartPostService;
// import com.zmn.oms.services.interfaces.fcorderpart.OrderFactoryPartService;
// import com.zmn.oms.services.interfaces.invoice.OrderInvoiceService;
// import com.zmn.oms.services.interfaces.master.OrderMasterService;
// import com.zmn.oms.services.interfaces.member.OrderMemberService;
// import com.zmn.oms.services.interfaces.nonstandard.OrderNonstandardService;
// import com.zmn.oms.services.interfaces.operation.OrderOperationService;
// import com.zmn.oms.services.interfaces.operator.OrderWorkOperatorService;
// import com.zmn.oms.services.interfaces.order.OrderExtendService;
// import com.zmn.oms.services.interfaces.orderattachment.OrderAttachmentService;
// import com.zmn.oms.services.interfaces.pay.OrderPayService;
// import com.zmn.oms.services.interfaces.product.OrderProductService;
// import com.zmn.oms.services.interfaces.refund.OrderWorkRefundDetailService;
// import com.zmn.oms.services.interfaces.remark.OrderRemarkDetailService;
// import com.zmn.oms.services.interfaces.remark.OrderRemarkService;
// import com.zmn.oms.services.interfaces.review.OmsOrderReviewService;
// import com.zmn.oms.services.interfaces.serviceitem.OrderServiceItemService;
// import com.zmn.oms.services.interfaces.shop.OrderShopService;
// import com.zmn.oms.services.interfaces.statement.OrderStatementService;
// import com.zmn.oms.services.interfaces.tag.OrderTagService;
// import com.zmn.oms.services.interfaces.track.OrderTrackService;
// import com.zmn.oms.services.interfaces.visit.OrderVisitService;
// import com.zmn.oms.services.interfaces.warranty.OrderWarrantyProductService;
// import com.zmn.oms.services.interfaces.warranty.OrderWarrantyService;
// import com.zmn.oms.services.interfaces.work.EsOrderWorkService;
// import com.zmn.oms.services.interfaces.work.OrderWorkService;
// import com.zmn.oms.services.interfaces.worktrack.WorkTrackService;
// import com.zmn.oms.task.es.business.interfaces.orderwork.SyncEsOrderWorkBService;
// import com.zmn.oms.third.deshiman.DeshimanConsts;
// import com.zmn.pay.common.constant.PayConsts;
// import com.zmn.performance.common.dro.order.OrderBehaviorDRO;
// import com.zmn.performance.dubbo.interfaces.order.OrderBehaviorListRemoteService;
// import com.zmn.ums.common.dro.weixincp.WeixincpExternalUserDRO;
// import com.zmn.ums.dubbo.interfaces.weixincp.WeixincpUserListRemoteService;
// import com.zmn.ums.dubbo.interfaces.weixincp.WeixincpUserModifyRemoteService;
// import org.apache.commons.lang3.StringUtils;
// import org.apache.dubbo.config.annotation.Reference;
// import org.slf4j.Logger;
// import org.slf4j.LoggerFactory;
// import org.springframework.beans.factory.annotation.Autowired;
// import org.springframework.beans.factory.annotation.Value;
// import org.springframework.stereotype.Service;
// import org.springframework.util.CollectionUtils;
//
// import javax.annotation.Resource;
// import java.util.*;
// import java.util.function.Function;
// import java.util.regex.Matcher;
// import java.util.regex.Pattern;
// import java.util.stream.Collectors;
//
// import static com.zmn.oms.common.constant.OrderConsts.CANCEL_PAY_TIMEOUT_ID;
//
// /**
//  * 类描述：同步订单实现
//  *
//  * @author lujia
//  * @date 2018/11/23 19:38
//  */
// @Service
// public class SyncEsOrderWorkBServiceImpl implements SyncEsOrderWorkBService {
//
//     private static final Logger logger = LoggerFactory.getLogger(SyncEsOrderWorkBServiceImpl.class);
//
//     @Autowired
//     private OrderWorkService orderWorkService;
//     @Autowired
//     private OrderVisitService orderVisitService;
//     @Autowired
//     private OrderDetailService orderDetailService;
//     @Autowired
//     private OrderExtendService orderExtendService;
//     @Autowired
//     private OrderMemberService orderMemberService;
//     @Autowired
//     private OrderMasterService orderMasterService;
//     @Autowired
//     private OrderProductService orderProductService;
//     @Autowired
//     private OrderServiceItemService orderWorkServiceItemService;
//     @Autowired
//     private OrderDiscountService orderDiscountService;
//     @Autowired
//     private OrderTrackService orderTrackService;
//     @Autowired
//     private OrderWarrantyService orderWarrantyService;
//     @Autowired
//     private OrderWarrantyProductService orderWarrantyProductService;
//     @Autowired
//     private OrderCommentService orderCommentService;
//     @Autowired
//     private OrderInvoiceService orderInvoiceService;
//     @Autowired
//     private OrderRemarkService orderRemarkService;
//     @Autowired
//     private OrderRemarkDetailService orderRemarkDetailService;
//     @Autowired
//     private OrderFactoryService orderFactoryService;
//     @Autowired
//     private OrderFactoryPartService orderFactoryPartService;
//     @Autowired
//     private OrderFactoryPartPostService orderFactoryPartPostService;
//     @Autowired
//     private EsOrderWorkService esOrderWorkService;
//     @Autowired
//     private OrderShopService orderShopService;
//     @Autowired
//     private OrderStatementService orderStatementService;
//     @Autowired
//     private OrderTmallExtendBService orderTmallExtendBService;
//     @Autowired
//     private OrderOperationService orderOperationService;
//     @Autowired
//     private OrderWorkListBService orderWorkListBService;
//     @Autowired
//     private OrderChangeRecordService orderChangeRecordService;
//     @Autowired
//     private OrderNonstandardService orderNonstandardService;
//     @Resource
//     private ZmnMQSender zmnMQSender;
//     @Resource
//     private EnterpriseWeChatService enterpriseWeChatService;
//     @Autowired
//     private OrderPostService orderPostService;
//     @Autowired
//     private WorkTrackService workTrackService;
//     @Autowired
//     private WorkTrackBService workTrackBService;
//     @Autowired
//     private OrderTagService orderTagService;
//     @Autowired
//     private OrderPayService orderPayService;
//     @Autowired
//     private OmsOrderReviewService orderReviewService;
//     @Autowired
//     private OrderWorkRefundDetailService orderWorkRefundDetailService;
//     @Autowired
//     private OrderAttachmentService orderAttachmentService;
//     @Autowired
//     private OrderWorkAcceptanceService orderWorkAcceptanceService;
//     @Autowired
//     private OrderWorkOperatorService orderWorkOperatorService;
//     @Autowired
//     private ServItemBService servItemBService;
//
//     @Reference(version = com.zmn.ums.dubbo.utils.DubboConsts.INTERFACE_VERSION, check = false)
//     private WeixincpUserListRemoteService weixincpUserListRemoteService;
//     @Reference(version = com.zmn.ums.dubbo.utils.DubboConsts.INTERFACE_VERSION, check = false)
//     private WeixincpUserModifyRemoteService weixincpUserModifyRemoteService;
//
//     @Reference(version = com.zmn.base.engineer.common.constants.DubboConsts.INTERFACE_VERSION, check = false)
//     private EngineerListRemoteService engineerListRemoteService;
//     @Reference(version = DubboConsts.INTERFACE_VERSION, check = false)
//     private AccountDetailListRemoteService accountDetailListRemoteSeravice;
//     @Reference(version = DubboConsts.INTERFACE_VERSION, check = false)
//     private InvoiceInfoListRemoteService invoiceInfoListRemoteService;
//     @org.apache.dubbo.config.annotation.Reference(version = com.zmn.performance.dubbo.consts.DubboConsts.INTERFACE_VERSION, check = false)
//     private OrderBehaviorListRemoteService orderBehaviorListRemoteService;
//     @Value("${spring.mq.topic.ums:''}")
//     String umsTopic;
//
//
//     @Override
//     public void sync(List<Long> orderIdList) {
//         if (CollectionUtils.isEmpty(orderIdList)) {
//             return;
//         }
//         // 初始化esOrderWork map容器
//         Map<Long, EsOrderWork> esOrderWorkMap = Maps.newHashMapWithExpectedSize(orderIdList.size());
//
//         // 工单list
//         // logger.info("orderWorkService.listEsOrderWorkByOrderIdList orderIdList={}", orderIdList);
//         List<OrderWork> orderWorkList = orderWorkService.listEsOrderWorkByOrderIdList(orderIdList);
//         // logger.info("orderWorkService.listEsOrderWorkByOrderIdList result={}", orderWorkList);
//         if (orderWorkList.isEmpty()) {
//             logger.error("#orderchange# sync fail, not found order id list : {}", JSON.toJSONString(orderIdList));
//             return;
//         }
//
//         Map<Long, OrderWork> orderWorkMap = orderWorkList.stream().collect(Collectors.toMap(OrderWork::getWorkId, orderWork -> orderWork, (entity1, entity2) -> entity1));
//         // 1.组装工单信息
//         processOrderWorkList(orderWorkMap, esOrderWorkMap);
//
//         // 1.1 补充渠道订单的扩展渠道订单号
//         List<OrderExtend> orderExtends = orderExtendService.listMiniOrderExtendByOrderIdList(orderIdList);
//         processOrderExtendData(orderIdList, orderExtends, esOrderWorkMap);
//
//         // 2. 组装订单明细数据
//         List<EsOrderDetailVO> orderDetailList = orderDetailService.listEsOrderDetailByOrderIdList(orderIdList);
//         Map<Long, EsOrderDetailVO> orderDetailMap = orderDetailList.stream().collect(Collectors.toMap(EsOrderDetailVO::getDetailId, orderDetail -> orderDetail, (entity1, entity2) -> entity1));
//         processOrderDetailList(orderDetailMap, esOrderWorkMap);
//
//         // 2.1 厂商单
//         List<OrderFactory> orderFactoryList = orderFactoryService.listEsOrderFactoryByOrderIdList(orderIdList);
//         if (!CollectionUtils.isEmpty(orderFactoryList)) {
//
//             List<OrderFactoryPart> orderFactoryPartList = orderFactoryPartService.listEsOrderFactoryPartByOrderIdList(orderIdList);
//             List<OrderFactoryPartPost> orderFactoryPartPostList = orderFactoryPartPostService.listEsOrderFactoryPartPostByOrderIdList(orderIdList);
//
//             Map<Long, OrderFactory> orderFactoryMap = Maps.newHashMap();
//             if (!CollectionUtils.isEmpty(orderFactoryList)) {
//                 orderFactoryMap = orderFactoryList.stream().collect(Collectors.toMap(OrderFactory::getFcOrderId, orderFactory -> orderFactory, (entity1, entity2) -> entity1));
//             }
//
//             Map<Long, List<OrderFactoryPart>> orderFactoryPartMap = Maps.newHashMap();
//             if (!CollectionUtils.isEmpty(orderFactoryPartList)) {
//                 orderFactoryPartMap = orderFactoryPartList.stream().collect(Collectors.groupingBy(OrderFactoryPart::getOrderId));
//             }
//
//             Map<Long, List<OrderFactoryPartPost>> orderFactoryPartPostMap = Maps.newHashMap();
//             if (!CollectionUtils.isEmpty(orderFactoryPartPostList)) {
//                 orderFactoryPartPostMap = orderFactoryPartPostList.stream().collect(Collectors.groupingBy(OrderFactoryPartPost::getOrderId));
//             }
//             processOrderFactoryList(esOrderWorkMap, orderFactoryMap, orderFactoryPartMap, orderFactoryPartPostMap);
//         }
//
//         // 3. 组装工程师list数据
//         List<OrderMaster> orderMasterList = orderMasterService.listMasterByOrderIdList(orderIdList);
//         if (!orderMasterList.isEmpty()) {
//             Map<Long, List<OrderMaster>> orderWorkMasterGroupMap = orderMasterList.stream().collect(Collectors.groupingBy(OrderMaster::getWorkId));
//             processOrderMaster(orderWorkMasterGroupMap, esOrderWorkMap);
//         }
//
//         // 4.组装操作人员列表在 1.组装工单信息中处理
//
//         // 5.组装工单产品列表
//         // 产品列表
//         List<OrderProduct> orderProductList = orderProductService.listOrderProductByOrderIdList(orderIdList);
//         Map<Long, List<OrderProduct>> orderProductGroupMap = orderProductList.stream().collect(Collectors.groupingBy(OrderProduct::getOrderId));
//         processOrderProduct(orderProductGroupMap, esOrderWorkMap);
//
//         // 6.组装工单服务项
//         // 服务项目
//         List<OrderServiceItem> orderServiceItemList = orderWorkServiceItemService.listOrderServiceItemByOrderIdList(orderIdList);
//         if (!orderServiceItemList.isEmpty()) {
//             Map<Long, List<OrderServiceItem>> orderWorkServiceItemGroupMap = orderServiceItemList
//                     .stream().collect(Collectors.groupingBy(OrderServiceItem::getOrderId));
//             processOrderServiceItem(orderWorkServiceItemGroupMap, esOrderWorkMap);
//         }
//
//         // 优惠
//         // 7. 组装工单优惠
//         List<OrderDiscount> orderDiscountList = orderDiscountService.listOrderDiscountByOrderIdList(orderIdList);
//         Map<Long, List<OrderDiscount>> orderDiscountGroupMap = null;
//         if (!orderDiscountList.isEmpty()) {
//             orderDiscountGroupMap = orderDiscountList.stream().collect(Collectors.groupingBy(OrderDiscount::getOrderId));
//             processOrderDiscount(orderDiscountGroupMap, esOrderWorkMap);
//         }
//
//         // 会员单
//         // 8. 组装会员订单数据
//         List<OrderMember> orderMemberList = orderMemberService.listEsOrderMemberByOrderIdList(orderIdList);
//         if (!orderMemberList.isEmpty()) {
//             Map<Long, OrderMember> orderMemberMap = orderMemberList.stream()
//                     .collect(Collectors.toMap(OrderMember::getMemberOrderId, orderMember -> orderMember, (entity1, entity2) -> entity1));
//             processOrderMember(orderMemberMap, orderDiscountGroupMap, esOrderWorkMap);
//         }
//
//         // 9. 财务数据
//         // 9.1 支付凭证
//         List<OrderPay> orderPayList = orderPayService.listOrderPayByOrderIdList(orderIdList);
//         if (CollectionUtil.isNotNullOrEmpty(orderPayList)) {
//             Map<Long, List<OrderPay>> voucherOrderGroup = orderPayList.stream().collect(Collectors.groupingBy(OrderPay::getWorkId));
//             processVoucherOrder(voucherOrderGroup,esOrderWorkMap);
//         }
//
//         // 9.2 服务商提留与渠道佣金 ---仅服务平台:言而有信
//         //TODO ERP
//         List<Long> accountIdList = orderWorkList.stream()
//                                 .filter(orderWork -> (Objects.equals(GlobalConsts.PLAT_MARK_YEYX,orderWork.getPlatWork()) && !NumberUtil.isNullOrZero(orderWork.getAccountId())))
//                                 .map(OrderWork::getAccountId).collect(Collectors.toList());
//         if (!CollectionUtils.isEmpty(accountIdList)){
//             ResponseDTO<List<AccountDetailDRO>> orderDrawningInfoReps = accountDetailListRemoteSeravice.listOrderAccountDetails(accountIdList);
//             // logger.info("服务商提留查询出参：{}",JSONObject.toJSONString(orderDrawningInfoReps));
//             if (orderDrawningInfoReps.isSuccess() && !CollectionUtils.isEmpty(orderDrawningInfoReps.getData())){
//                 Map<Long, AccountDetailDRO> drawingInfoDROMap = orderDrawningInfoReps.getData().stream().collect(Collectors.toMap(AccountDetailDRO::getOrderId, OrderDrawingInforDRO -> OrderDrawingInforDRO, (v1, v2) -> v1));
//                 processServiceProviderRewardAmount(drawingInfoDROMap, esOrderWorkMap);
//             }
//         }
//
//         // 10. 组装工单跟单数据
//         List<OrderTrack> orderWorkTrackList = orderTrackService.listOrderTrackByOrderIdList(orderIdList);
//         if (!orderWorkTrackList.isEmpty()) {
//             Map<Long, List<OrderTrack>> orderWorkTrackGroupMap = orderWorkTrackList.stream().collect(Collectors.groupingBy(OrderTrack::getWorkId));
//             processOrderTrack(orderWorkTrackGroupMap, esOrderWorkMap);
//         }
//
//         // 11.组装保单数据
//         // 订单保单
//         List<OrderWarranty> orderWarrantyCodeList = orderWarrantyService.listOrderWarrantyCodeByOrderIdList(orderIdList);
//         List<OrderWarrantyProduct> warrantyProducts = orderWarrantyProductService.listOrderWarrantyProductByOrderIdList(orderIdList);
//         if (!orderWarrantyCodeList.isEmpty()) {
//             Map<Long, OrderWarranty> orderWarrantyMap = orderWarrantyCodeList.stream()
//                     .collect(Collectors.toMap(OrderWarranty::getWarrId, orderWarranty -> orderWarranty, (entity1, entity2) -> entity1));
//
//             Map<Long, List<OrderWarrantyProduct>> warrantyProductMap = warrantyProducts.stream().collect(Collectors.groupingBy(OrderWarrantyProduct::getWarrId));
//             processOrderWarranty(orderWarrantyMap, warrantyProductMap, esOrderWorkMap);
//         }
//
//         // 12.组装订单评价数据
//         List<OrderComment> orderComments = orderCommentService.listOrderCommentByOrderIdList(orderIdList);
//         if (CollectionUtil.isNotNullOrEmpty(orderComments)) {
//             Map<Long, OrderComment> commentDetailDROMap = orderComments
//                     .stream()
//                     .collect(Collectors.toMap(OrderComment::getCommentId, orderComment -> orderComment, (entity1, entity2) -> entity1));
//             processOrderComment(commentDetailDROMap, esOrderWorkMap);
//         }
//
//         // 13. 组装订单发票数据
//         List<Long> workIdList = orderWorkList.stream().map(OrderWork::getWorkId).collect(Collectors.toList());
//         List<InvoiceInfoDRO> invoiceList = invoiceInfoListRemoteService.listInvoiceInfoByBillIds(workIdList).getData();
//         if (!CollectionUtils.isEmpty(invoiceList)) {
//             Map<Long, InvoiceInfoDRO> orderInvoiceMap = invoiceList.stream().collect(Collectors.toMap(InvoiceInfoDRO::getBillId, orderInvoice -> orderInvoice, (v1, v2) -> {
//                 if (!Objects.equals(v1.getOperationType(), InvoiceInfoConstant.INVOICE_OPERATION_TYPE_WRITE_ON) && !Objects.equals(v2.getOperationType(), InvoiceInfoConstant.INVOICE_OPERATION_TYPE_WRITE_ON)) {
//                     if (v1.getCreateTime().after(v2.getCreateTime())) {
//                         return v1;
//                     } else {
//                         return v2;
//                     }
//                 } else if (Objects.equals(v1.getOperationType(), InvoiceInfoConstant.INVOICE_OPERATION_TYPE_WRITE_ON)) {
//                     return v2;
//                 } else {
//                     return v1;
//                 }
//             }));
//             processOrderInvoice(orderInvoiceMap, esOrderWorkMap);
//         }
//
//         // 14. 组装订单备注数据 失败原因，弃单原因， 回访内容
//         List<OrderRemarkDetail> orderRemarkDetailList = orderRemarkDetailService.listOrderRemarkDetailByOrderIdList(orderIdList);
//         try{
//             List<OrderRemark> orderRemarkList = orderRemarkService.listOrderRemarkByOrderIdList(orderIdList);
//             if (!orderRemarkList.isEmpty()) {
//                 Map<Integer, Map<Long, OrderRemark>> orderRemarkGroupMap = orderRemarkList.stream()
//                         .collect(Collectors.groupingBy(OrderRemark::getType, Collectors.toMap(OrderRemark::getWorkId, orderRemark -> orderRemark, (entity1, entity2) -> entity1)));
//                 Map<Long, List<OrderRemarkDetail>> orderRemarkDetailGroupMap = orderRemarkDetailList
//                         .stream().collect(Collectors.groupingBy(OrderRemarkDetail::getRemarkId));
//                 processOrderRemark(orderRemarkGroupMap, orderRemarkDetailGroupMap, esOrderWorkMap);
//             }
//         } catch (Exception ex){
//             ex.printStackTrace();
//         }
//
//         // 15. 组装订单店铺数据
//         List<OrderShop> orderShopList = orderShopService.listOrderShopByOrderIdList(orderIdList);
//         if (!orderShopList.isEmpty()) {
//             Map<Long, OrderShop> orderShopMap = orderShopList.stream().collect(Collectors.toMap(OrderShop::getShopOrderId, e -> e, (entity1, entity2) -> entity1));
//             processOrderShop(orderShopMap, esOrderWorkMap);
//         }
//
//         // 16. 组装订单结算数据
//         List<OrderStatement> orderStatementList = orderStatementService.listOrderStatementByOrderIdList(orderIdList);
//         if (!orderStatementList.isEmpty()) {
//             Map<Long, OrderStatement> orderStatementMap = orderStatementList.stream().collect(Collectors.toMap(OrderStatement::getWorkId, e -> e, (entity1, entity2) -> entity1));
//             processOrderStatement(orderStatementMap, esOrderWorkMap);
//         }else {
//             esOrderWorkMap.forEach((workId, orderWork) -> {
//                 orderWork.setChannelStatementStatus(GlobalConsts.NO);
//                 orderWork.setSpStatementStatus(GlobalConsts.NO);
//             });
//         }
//
//         // 17. 计价器报价
//         List<OrderOperation> orderOperations = orderOperationService.listByOrderIdList(orderIdList);
//         if (!orderOperations.isEmpty()) {
//             Map<Long, OrderOperation> orderOperationMap = orderOperations.stream().collect(Collectors.toMap(OrderOperation::getOrderId, e -> e, (entity1, entity2) -> entity1));
//             processOrderOperation(orderOperationMap, esOrderWorkMap);
//         }
//
//         // 18.组装工单备注详情
//         Map<Long, List<OrderRemarkDetail>> remarkDetailMap = orderRemarkDetailList.stream().collect(Collectors.groupingBy(OrderRemarkDetail::getWorkId));
//         processOrderRemarkDetail(esOrderWorkMap, remarkDetailMap);
//
//         // 19.组装是否关注企业微信的数据 (上门用户 是否关注企业微信 扫描企业微信二维码)
//         com.zmn.common.dto2.ResponseDTO<List<Long>> subOrderIds = weixincpUserListRemoteService.listSubOrderIdByOrderIds(orderIdList);
//         if (subOrderIds.isSuccess()) {
//             processSubWeixincp(esOrderWorkMap, subOrderIds.getData());
//         }
//
//         // 20. 组装改约次数
//         List<OrderChangeRecord> orderChangeRecordList = orderChangeRecordService.listByOrderIdList(orderIdList);
//         if (!orderChangeRecordList.isEmpty()) {
//             Map<Long, OrderChangeRecord> orderChangeRecordMap = orderChangeRecordList.stream().collect(Collectors.toMap(OrderChangeRecord::getOrderId, e -> e, (entity1, entity2) -> entity1));
//             processOrderChangeRecord(orderChangeRecordMap, esOrderWorkMap);
//         }
//
//         // 21. 组装非标信息
//         List<OrderNonstandard> orderNonstandardList = orderNonstandardService.listNonstandardByOrderIdList(orderIdList);
//         if (!orderNonstandardList.isEmpty()) {
//             esOrderWorkMap.forEach((orderId, orderWork) -> {
//                 List<OrderNonstandard> collect = orderNonstandardList.stream().filter(e -> Objects.equals(e.getOrderId(), orderId)).collect(Collectors.toList());
//                 List<EsOrderNonstandard> esOrderNonstandardList = BeanMapper.mapList(collect, EsOrderNonstandard.class);
//                 orderWork.setOrderNonstandardList(esOrderNonstandardList);
//             });
//         }
//         // 22. 快递信息list数据
//         List<OrderPost> orderPostList = orderPostService.listOrderPostByOrderIds(orderIdList);
//         if (!orderPostList.isEmpty()) {
//             Map<Long, List<OrderPost>> orderWorkPostGroupMap = orderPostList.stream().collect(Collectors.groupingBy(OrderPost::getOrderId));
//             processOrderPost(orderWorkPostGroupMap, esOrderWorkMap);
//         }
//         // 23. 计价器是否有效
//         // 获取有计价器是否有效的工单号
//         Set<Long> quotationSet = orderWorkList.stream()
//                 .filter(item -> {
//                     return item.getStatus() >= OrderStatusConsts.WORK_STATUS_CHECKOUT && Objects.equals(item.getServItemType(), OrderConsts.SERVICE_ITEM_TYPE_FAULT);})
//                 .map(OrderWork::getWorkId).collect(Collectors.toSet());
//         if (CollectionUtil.isNotNullOrEmpty(quotationSet)) {
//             ResponseDTO<List<OrderBehaviorDRO>> orderBehaviorResponse = orderBehaviorListRemoteService.getByWorkIds(quotationSet);
//             if (orderBehaviorResponse.isSuccess() && CollectionUtil.isNotNullOrEmpty(orderBehaviorResponse.getData())) {
//                 List<OrderBehaviorDRO> orderBehaviorDROS = orderBehaviorResponse.getData();
//                 Map<Long, OrderBehaviorDRO> droMap = orderBehaviorDROS.stream().collect(Collectors.toMap(OrderBehaviorDRO::getWorkId, e -> e, (v1, v2) -> v1));
//                 esOrderWorkMap.forEach((k, v) -> {
//                     OrderBehaviorDRO dro = droMap.get(v.getId());
//                     if (Objects.isNull(dro) || NumberUtil.isNullOrZero(dro.getTariff())) {
//                         return;
//                     }
//                     v.setIsQuotationValid(Objects.equals(dro.getTariff(), GlobalConsts.YES));
//                 });
//             }
//         }
//
//         // 用户-待取消
//         List<OrderWorkTrack> orderWorkTracks = workTrackService.queryListByOrderIdsSrcMaster(orderIdList);
//         processOrderWorkTrack(esOrderWorkMap,orderWorkTracks);
//
//         // 24.组装订单标签
//         List<OrderTag> orderTagList = orderTagService.listOrderTagByOrderIdList(orderIdList);
//         if (CollectionUtil.isNotNullOrEmpty(orderTagList)) {
//             Map<Long, List<OrderTag>> orderTagMap = orderTagList.stream().collect(Collectors.groupingBy(OrderTag::getWorkId));
//             this.processOrderTag(orderTagMap, esOrderWorkMap);
//         }
//         // 工单附件
//         List<OrderAttachment> orderAttachments = orderAttachmentService.listAttachmentByOrderIdList(orderIdList);
//         if (CollectionUtil.isNotNullOrEmpty(orderAttachments)) {
//             Map<Long, List<OrderAttachment>> orderAttachmentMap = orderAttachments.stream().collect(Collectors.groupingBy(OrderAttachment::getOrderId));
//             this.processOrderAttachment(orderAttachmentMap, esOrderWorkMap);
//         }
//         // 审批记录
//         List<OmsOrderReview> orderReviewList = orderReviewService.listOrderReviewByOrderIdList(orderIdList);
//         if (CollectionUtil.isNotNullOrEmpty(orderReviewList)) {
//             Map<Long, List<OmsOrderReview>> orderReviewMap = orderReviewList.stream().collect(Collectors.groupingBy(OmsOrderReview::getWorkId));
//             this.processOrderReview(orderReviewMap, esOrderWorkMap);
//         }
//
//         // 订单验收
//         List<OrderWorkAcceptance> orderWorkAcceptanceList = orderWorkAcceptanceService.listOrderWorkAcceptanceByOrderIdList(orderIdList);
//         if (CollectionUtil.isNotNullOrEmpty(orderWorkAcceptanceList)) {
//             Map<Long, List<OrderWorkAcceptance>> orderWorkAcceptanceMap = orderWorkAcceptanceList.stream().collect(Collectors.groupingBy(OrderWorkAcceptance::getWorkId));
//             this.processOrderWorkAcceptance(orderWorkAcceptanceMap, esOrderWorkMap);
//         }
//
//         // 多次上门
//         List<OrderVisit> orderVisitList = orderVisitService.listOrderVisitByOrderIdList(orderIdList);
//         if (CollectionUtil.isNotNullOrEmpty(orderVisitList)) {
//             Map<Long, List<OrderVisit>> orderVisitMap = orderVisitList.stream().collect(Collectors.groupingBy(OrderVisit::getOrderId));
//             this.processOrderVisit(orderVisitMap, esOrderWorkMap);
//         }
//
//         // 退款审核状态
//         if (CollectionUtil.isNullOrEmpty(orderReviewList)) {
//             esOrderWorkMap.forEach((k,v)->{
//                 v.setRefundWorkReviewStatus(GlobalConsts.NONE);
//             });
//         }else {
//             Map<Long, List<OmsOrderReview>> orderReviewMap = orderReviewList.stream().collect(Collectors.groupingBy(OmsOrderReview::getWorkId));
//             this.processRefundWorkReviewStatus(orderReviewMap, esOrderWorkMap);
//         }
//
//         // 退款详情
//         List<OrderWorkRefundDetail> orderWorkRefundDetails = orderWorkRefundDetailService.listOrderWorkRefundDetailByOrderIdList(orderIdList);
//         if (CollectionUtil.isNotNullOrEmpty(orderWorkRefundDetails)) {
//             Map<Long, List<OrderWorkRefundDetail>> orderWorkRefundDetailMap = orderWorkRefundDetails.stream().collect(Collectors.groupingBy(OrderWorkRefundDetail::getWorkId));
//             this.processOrderRefundDetail(orderWorkRefundDetailMap, esOrderWorkMap);
//         }
//
//         // 处理照片审核状态
//         processImageReviewStatus(orderAttachments, orderExtends, esOrderWorkMap);
//
//         // 组装订单操作信息
//         /*List<OrderWorkOperator> orderWorkOperatorList = orderWorkOperatorService.listEsOrderWorkOperatorByOrderIdList(orderIdList);
//         if (CollectionUtil.isNotNullOrEmpty(orderWorkOperatorList)) {
//             Map<Long, OrderWorkOperator> orderWorkOperatorMap = orderWorkOperatorList.stream().collect(Collectors.toMap(OrderWorkOperator::getWorkId, e -> e, (entity1, entity2) -> entity1));
//             this.processOrderWorkOperator(orderWorkOperatorMap, esOrderWorkMap);
//         }*/
//
//         // 保存
//         esOrderWorkService.saveAll(esOrderWorkMap.values());
//         logger.debug("#orderchange# sync end orderid list : {}", JSON.toJSONString(orderIdList));
//     }
//
//     /**
//      * 组装订单操作信息
//      * @param orderWorkOperatorMap
//      * @param esOrderWorkMap
//      */
//     /*private void processOrderWorkOperator(Map<Long, OrderWorkOperator> orderWorkOperatorMap, Map<Long, EsOrderWork> esOrderWorkMap) {
//         orderWorkOperatorMap.forEach((workId, orderWorkOperator)->{
//             EsOrderWork esOrderWork = esOrderWorkMap.get(workId);
//             if(esOrderWork == null){
//                 return;
//             }
//             esOrderWork.setEsOrderWorkOperator(BeanMapper.map(orderWorkOperator, EsOrderWorkOperator.class));
//         });
//     }*/
//
//     private void processOrderRefundDetail(Map<Long, List<OrderWorkRefundDetail>> orderWorkRefundDetailMap, Map<Long, EsOrderWork> esOrderWorkMap) {
//         orderWorkRefundDetailMap.forEach((workId,orderWorkRefundDetail)->{
//             EsOrderWork esOrderWork = esOrderWorkMap.get(workId);
//             if(esOrderWork == null){
//                 return;
//             }
//             esOrderWork.setRefundDetail(BeanMapper.map(orderWorkRefundDetail.get(0), EsOrderWorkRefundDetail.class));
//         });
//     }
//
//
//     /**
//      * 处理新跟单字段
//      *
//      * @param esOrderWorkMap
//      * @param orderWorkTracks
//      */
//     private void processOrderWorkTrack(Map<Long, EsOrderWork> esOrderWorkMap, List<OrderWorkTrack> orderWorkTracks) {
//         if (CollectionUtil.isNullOrEmpty(orderWorkTracks)) {
//             return;
//         }
//
//         Map<Long, List<OrderWorkTrack>> orderTrackMap = orderWorkTracks.stream().collect(Collectors.groupingBy(OrderWorkTrack::getOrderId));
//         for (Map.Entry<Long, EsOrderWork> entry : esOrderWorkMap.entrySet()) {
//             Long k = entry.getKey();
//             EsOrderWork v = entry.getValue();
//
//             List<OrderWorkTrack> trackList = orderTrackMap.get(k);
//             if (CollectionUtil.isNullOrEmpty(trackList)) {
//                 continue;
//             }
//
//             // 跟单信息
//             v.setWorkTrackList(BeanMapper.mapList(trackList, EsWorkTrack.class));
//
//             // 待取消
//             v.setWaitCancel(workTrackBService.getUserWaitCancelStatus(trackList));
//         }
//     }
//
//     /**
//      * 处理订单修改记录
//      * @param orderChangeRecordMap
//      * @param esOrderWorkMap
//      */
//     private void processOrderChangeRecord(Map<Long, OrderChangeRecord> orderChangeRecordMap, Map<Long, EsOrderWork> esOrderWorkMap) {
//         esOrderWorkMap.forEach((k, v) -> {
//
//             if (!orderChangeRecordMap.containsKey(k)) {
//                 return;
//             }
//
//             // 改约次数
//             OrderChangeRecord orderChangeRecord = orderChangeRecordMap.get(k);
//             v.setDutyTimeModifyCount(orderChangeRecord.getDutyTimeModifyCount());
//             v.setDistributeModifyCount(orderChangeRecord.getDistributeCount());
//             // 首次预约时间、首次操作预约时间点、末次预约时间、末次操作预约时间点、上次上门扫码时间，末次上门扫码时间
//             v.setFirstDutyTime(orderChangeRecord.getFirstDutyTime());
//             v.setFirstDutyOptTime(orderChangeRecord.getFirstDutyOptTime());
//             v.setLastDutyTime(orderChangeRecord.getLastDutyTime());
//             v.setLastDutyOptTime(orderChangeRecord.getLastDutyOptTime());
//             v.setFirstVisitScanTime(orderChangeRecord.getFirstVisitScanTime());
//             v.setLastVisitScanTime(orderChangeRecord.getLastVisitScanTime());
//             v.setLastPrepayAmountOptTime(orderChangeRecord.getLastPrepayAmountOptTime());
//             // 责任工程师
//             v.setCancelLiableMasterId(orderChangeRecord.getCancelLiableMasterId());
//             v.setCancelLiableMasterName(orderChangeRecord.getCancelLiableMasterName());
//
//         });
//     }
//
//     /**
//      * 处理企业微信关注事件
//      * @param esOrderWorkMap
//      * @param subOrderIds
//      */
//     private void processSubWeixincp(Map<Long, EsOrderWork> esOrderWorkMap, List<Long> subOrderIds) {
//         esOrderWorkMap.forEach((k, v) -> {
//
//             if (!subOrderIds.contains(k)) {
//                 return;
//             }
//
//             v.setSubWeixincp(GlobalConsts.YES);
//         });
//     }
//
//     /**
//      * 发送mq
//      * @param orderIds
//      */
//     private void sendOmsMq(List<Long> orderIds){
//         String key = StringUtil.getRandomsString(32);
//         logger.debug("#es#syncByVisitUserId#orderwork#sendOmsMq key : {}", key);
//         zmnMQSender.send(MqTopicConsts.ZMN_TOPIC_OMS, MqTagConsts.ZMN_TOPIC_OMS_CHANGE_ORDER_WORK, key, JSON.toJSONString(orderIds));
//     }
//
//     /**
//      * 处理渠道结算
//      * @param orderStatementMap
//      * @param esOrderWorkMap
//      */
//     private void processOrderStatement(Map<Long, OrderStatement> orderStatementMap, Map<Long, EsOrderWork> esOrderWorkMap) {
//         esOrderWorkMap.forEach((workId, orderWork) -> {
//             OrderStatement orderStatement = orderStatementMap.get(workId);
//             if (orderStatement != null) {
//                 orderWork.setChannelStatementAmount(orderStatement.getChannelStatementAmount());
//                 orderWork.setChannelStatementStatus(Optional.ofNullable(orderStatement.getChannelStatementStatus()).orElse(GlobalConsts.NO));
//                 orderWork.setChannelStatementRemark(orderStatement.getChannelStatementRemark());
//                 orderWork.setChannelStatementCanTime(orderStatement.getChannelStatementCanTime());
//                 orderWork.setSpStatementStatus(orderStatement.getSpStatementStatus());
//                 orderWork.setSpStatementAmount(orderStatement.getSpStatementAmount());
//                 orderWork.setSpStatementTime(orderStatement.getSpStatementTime());
//                 orderWork.setSpStatementRemark(orderStatement.getSpStatementRemark());
//             }
//         });
//     }
//
//     /**
//      * 处理订单店铺
//      * @param orderShopMap
//      * @param esOrderWorkMap
//      */
//     private void processOrderShop(Map<Long, OrderShop> orderShopMap, Map<Long, EsOrderWork> esOrderWorkMap) {
//         orderShopMap.forEach((orderId, orderShop) -> {
//             EsOrderWork esOrderWork = esOrderWorkMap.get(orderId);
//             if (esOrderWork == null) {
//                 return;
//             }
//
//             EsOrderWorkShop orderWorkShop = EsOrderWorkShop.builder()
//                     .shopId(orderShop.getShopId())
//                     .shopName(orderShop.getShopName())
//                     .build();
//
//             esOrderWork.setShopOrder(orderWorkShop);
//         });
//     }
//
//     /**
//      * 组装服务商提留 渠道费信息
//      * @param drawingInfoDROMap
//      * @param esOrderWorkMap
//      */
//     private void processServiceProviderRewardAmount(Map<Long,AccountDetailDRO> drawingInfoDROMap, Map<Long,EsOrderWork> esOrderWorkMap) {
//
//         drawingInfoDROMap.forEach((orderId, accountDetail) -> {
//             EsOrderWork esOrderWork = esOrderWorkMap.get(orderId);
//             if (Objects.isNull(esOrderWork)) {
//                 return;
//             }
//
//             // 渠道佣金
//             esOrderWork.setChannelAmount(accountDetail.getChannelCommission());
//             // 服务商提留
//             esOrderWork.setServiceProviderRewardAmount(accountDetail.getSpReserveAmount());
//         });
//     }
//
//
//     /**
//      * 组装厂商订单
//      * @param esOrderWorkMap
//      * @param orderFactoryMap
//      * @param orderFactoryPartMap
//      * @param orderFactoryPartPostMap
//      */
//     private void processOrderFactoryList(Map<Long, EsOrderWork> esOrderWorkMap,
//                                          Map<Long, OrderFactory> orderFactoryMap,
//                                          Map<Long, List<OrderFactoryPart>> orderFactoryPartMap,
//                                          Map<Long, List<OrderFactoryPartPost>> orderFactoryPartPostMap) {
//
//         esOrderWorkMap.forEach((orderId, esOrderWork) -> {
//
//             if (!orderFactoryMap.containsKey(orderId)) {
//                 return;
//             }
//
//             OrderFactory orderFactory = orderFactoryMap.get(orderId);
//             EsOrderWorkFactory esOrderFactory = new EsOrderWorkFactory();
//             esOrderFactory.setBrandId(orderFactory.getFcBrandId());
//             esOrderFactory.setBrandName(orderFactory.getFcBrandName());
//             esOrderFactory.setProductId(orderFactory.getFcProductId());
//             esOrderFactory.setProductName(orderFactory.getFcProductName());
//             esOrderFactory.setFactoryId(orderFactory.getFactoryId());
//             esOrderFactory.setHasRemoteAmount(!NumberUtil.isNullOrZero(orderFactory.getRemoteAmount()));
//             esOrderFactory.setRemoteAmount(orderFactory.getRemoteAmount());
//
//             // 审核状态
//             Integer fcPartReviewStatus = orderFactory.getFcPartReviewStatus();
//             Integer partReviewStatus = orderFactory.getPartReviewStatus();
//             List<Integer> partReviewStatusList = Lists.newArrayList(fcPartReviewStatus, partReviewStatus);
//             esOrderFactory.setPartReviewStatus(partReviewStatusList.toArray(new Integer[partReviewStatusList.size()]));
//
//             // 厂商配件相关
//             if (orderFactoryPartMap.containsKey(orderId)) {
//                 List<OrderFactoryPart> orderFactoryPartList = orderFactoryPartMap.get(orderId);
//
//                 Set<Integer> partSrcSet = orderFactoryPartList.stream().map(OrderFactoryPart::getSrc).collect(Collectors.toSet());
//                 esOrderFactory.setPartSrc(partSrcSet.toArray(new Integer[partSrcSet.size()]));
//             }
//
//             // 厂商配件邮寄相关
//             if (orderFactoryPartPostMap.containsKey(orderId)) {
//                 List<OrderFactoryPartPost> orderFactoryPartPostList = orderFactoryPartPostMap.get(orderId);
//
//                 Set<Integer> postTypeSet = orderFactoryPartPostList.stream().map(OrderFactoryPartPost::getFcOrderPartPostType).collect(Collectors.toSet());
//                 Set<Integer> postStatusSet = orderFactoryPartPostList.stream().map(OrderFactoryPartPost::getStatus).collect(Collectors.toSet());
//                 esOrderFactory.setPostStatus(postStatusSet.toArray(new Integer[postStatusSet.size()]));
//                 esOrderFactory.setPostType(postTypeSet.toArray(new Integer[postStatusSet.size()]));
//
//                 List<EsOrderWorkFactoryPartPost> factoryPartPostList = Lists.newArrayListWithCapacity(orderFactoryPartPostList.size());
//                 orderFactoryPartPostList.forEach(e -> factoryPartPostList.add(new EsOrderWorkFactoryPartPost(e.getStatus(), e.getFcOrderPartPostType())));
//                 esOrderWork.setFactoryPartPostList(factoryPartPostList);
//             }
//
//             esOrderWork.setFactoryOrder(esOrderFactory);
//         });
//     }
//
//     /**
//      * 组装工单备注数据
//      *
//      * @param orderRemarkGroupMap       工单备注map
//      * @param orderRemarkDetailGroupMap 工单备注详情map
//      * @param esOrderWorkMap            es order map
//      */
//     private void processOrderRemark(Map<Integer, Map<Long, OrderRemark>> orderRemarkGroupMap,
//                                     Map<Long, List<OrderRemarkDetail>> orderRemarkDetailGroupMap,
//                                     Map<Long, EsOrderWork> esOrderWorkMap) {
//
//         // 弃单原因
//         Map<Long, OrderRemark> discardWorkMap = orderRemarkGroupMap.get(OrderConsts.ORDER_REMARK_TYPE_CANCEL);
//         // 回访原因
//         Map<Long, OrderRemark> replyWorkMap = orderRemarkGroupMap.get(OrderConsts.ORDER_REMARK_TYPE_REPLY);
//         // 失败原因
//         Map<Long, OrderRemark> failWorkMap = orderRemarkGroupMap.get(OrderConsts.ORDER_REMARK_TYPE_CANCEL);
//
//         esOrderWorkMap.forEach((key, value) -> {
//             Long workId = value.getId();
//
//             // 弃单备注
//             OrderRemark discardRemark = null;
//             if (discardWorkMap != null) {
//                 discardRemark = discardWorkMap.get(workId);
//             }
//
//             // 回访备注
//             OrderRemark replyRemark = null;
//             if (replyWorkMap != null) {
//                 replyRemark = replyWorkMap.get(workId);
//             }
//
//             // 失败备注
//             OrderRemark failRemark = null;
//             if (failWorkMap != null) {
//                 failRemark = failWorkMap.get(workId);
//             }
//
//             // 弃单
//             if (discardRemark != null) {
//                 // 设置超时未支付标识为 否
//                 value.setTimeoutPayCancel(GlobalConsts.NO);
//                 value.setDiscardContent(StringUtils.defaultString(discardRemark.getContent()));
//                 List<OrderRemarkDetail> discardDetailList = orderRemarkDetailGroupMap.get(discardRemark.getRemarkId());
//                 if (discardDetailList != null && !discardDetailList.isEmpty()) {
// //                    StringBuilder sbr = new StringBuilder();
// //                    discardDetailList.forEach(discardDetail -> {
// //                        sbr.append(discardDetail.getMapName());
// //                        sbr.append(",");
// //                    });
// //                    sbr.append(value.getDiscardContent());
// //                    value.setDiscardContent(sbr.toString());
//
//                     // 是否有超时未支付标识
//                     boolean timeout = discardDetailList.stream().anyMatch(e -> Objects.equals(e.getMapId(), CANCEL_PAY_TIMEOUT_ID));
//                     if (timeout) {
//                         value.setTimeoutPayCancel(GlobalConsts.YES);
//                     }
//                 }
//             }
//
//             // 回访
//             if (replyRemark != null) {
//                 value.setReplyContent(StringUtils.defaultString(replyRemark.getContent()));
//               /*  List<OrderRemarkDetail> replyDetailList = orderRemarkDetailGroupMap.get(replyRemark.getRemarkId());
//                 if (replyDetailList != null && !replyDetailList.isEmpty()) {
//                     StringBuilder sbr = new StringBuilder();
//                     replyDetailList.forEach(replyDetail -> {
//                         sbr.append(replyDetail.getMapName());
//                         sbr.append(",");
//                     });
//                     sbr.append(value.getReplyContent());
//                     value.setReplyContent(sbr.toString());
//                 }*/
//             }
//
//             // 失败
//             if (failRemark != null) {
// //                value.setFailContent(StringUtils.defaultString(failRemark.getContent()));
//                 List<OrderRemarkDetail> failDetailList = orderRemarkDetailGroupMap
//                         .get(failRemark.getRemarkId());
//                 if (failDetailList != null && !failDetailList.isEmpty()) {
//                     StringBuilder sbr = new StringBuilder();
//                     failDetailList.forEach(failDetail -> {
//                         sbr.append(failDetail.getMapName());
//                         sbr.append(",");
//                     });
// //                    sbr.append(value.getFailContent());
//                     value.setFailContent(sbr.toString());
//                     //失败原因
//                     List<Integer> failMapIdList = failDetailList.stream().filter(e -> !NumberUtil.isNullOrZero(e.getMapId())).map(e -> e.getMapId()).distinct().collect(Collectors.toList());
//                     value.setFailMapIdList(failMapIdList);
//
//                     // 取消时选择了测试标签，可以把订单打为测试单,但是取消没有选择测试标签，不一定为测试单
//                     boolean isTest = failDetailList.stream().anyMatch(detail -> {
//                         return Objects.equals(detail.getMapId(), OrderConsts.CANCEL_TEST_ID);
//                     });
//                     if (isTest) {
//                         value.setIsTest(true);
//                     }
//                 }
//             }
//
//         });
//
//     }
//
//     /**
//      * 组装订单发票数据
//      *
//      * @param orderInvoiceMap 订单发票map
//      * @param esOrderWorkMap  es order map
//      */
//     private static void processOrderInvoice(Map<Long, InvoiceInfoDRO> orderInvoiceMap,
//                                      Map<Long, EsOrderWork> esOrderWorkMap) {
//         esOrderWorkMap.forEach((key, value) -> {
//             InvoiceInfoDRO orderInvoice = orderInvoiceMap.get(value.getId());
//             value.setHasInvoice(orderInvoice != null);
//             if (orderInvoice != null) {
//                 value.setInvoiceTime(orderInvoice.getCreateTime());
//             }
//         });
//     }
//
//     /**
//      * 组装订单评价数据
//      */
//     private void processOrderComment(Map<Long, OrderComment> commentMap, Map<Long, EsOrderWork> esOrderWorkMap) {
//
//         esOrderWorkMap.forEach((key,value)->{
//             OrderComment comment = commentMap.get(value.getOrderId());
//             if (Objects.isNull(comment)) {
//                 return;
//             }
//
//             value.setIsDefaultComment(Objects.equals(comment.getType(), OrderConsts.COMMENT_TYPE_DEFAULT));
//             value.setCommentScore(comment.getScore());
//             value.setCommentContent(Optional.ofNullable(comment.getContent()).orElse(""));
//             value.setCommentStatus(comment.getStatus());
//             value.setCommentTime(comment.getCreateTime());
//
//             if (CollectionUtil.isNotNullOrEmpty(comment.getDetailList())) {
//                 boolean userComment = Objects.equals(comment.getType(), OrderConsts.COMMENT_TYPE_USER);
//                 boolean visit = !comment.getDetailList().stream().anyMatch(e -> Objects.equals(e.getMapName(), "上门不准时"));
//                 if (userComment && visit) {
//                     value.setVisitOnTimeStatus(GlobalConsts.YES);
//                 }
//
//                 StringBuilder strb = new StringBuilder();
//                 for (OrderCommentDetail commentLabel : comment.getDetailList()) {
//                     strb.append(",");
//                     strb.append(commentLabel.getMapName());
//                 }
//                 value.setCommentContent(String.format("%s%s", strb.toString(), value.getCommentContent()));
//             }
//         });
//     }
//
//     /**
//      * 组装订单保单数据
//      *
//      * @param orderWarrantyMap 订单保单map
//      * @param orderWarrantyProductMap 订单保单产品map
//      * @param esOrderWorkMap   es order map
//      */
//     private void processOrderWarranty(Map<Long, OrderWarranty> orderWarrantyMap,
//                                       Map<Long, List<OrderWarrantyProduct>> orderWarrantyProductMap,
//                                       Map<Long, EsOrderWork> esOrderWorkMap) {
//         esOrderWorkMap.forEach((key, value) -> {
//             OrderWarranty orderWarranty = orderWarrantyMap.get(value.getOrderId());
//             if (orderWarranty == null) {
//                 return;
//             }
//
//             List<OrderWarrantyProduct> warrantyProducts = orderWarrantyProductMap.get(value.getOrderId());
//             if (CollectionUtil.isNullOrEmpty(warrantyProducts)) {
//                 return;
//             }
//
//             List<String> codes = warrantyProducts.stream()
//                     .filter(e -> StringUtil.isNotBlank(e.getCode()))
//                     .map(e -> e.getCode())
//                     .collect(Collectors.toList());
//
//             if (StringUtils.isNotBlank(orderWarranty.getCode())) {
//                 value.setWarrantyCodes(Lists.newArrayList(orderWarranty.getCode()));
//                 value.setHasWarrantyCode(StringUtils.isNotBlank(orderWarranty.getCode()));
//             } else {
//                 if (CollectionUtil.isNotNullOrEmpty(codes)) {
//                     value.setWarrantyCodes(codes);
//                     value.setHasWarrantyCode(CollectionUtil.isNotNullOrEmpty(codes));
//                 }
//             }
//
//             // 取保修卡最大过期时间
//             Comparator<OrderWarrantyProduct> comparator = Comparator.comparing(OrderWarrantyProduct::getExpiredTime);
//             warrantyProducts.stream().filter(e -> Objects.nonNull(e.getExpiredTime())).max(comparator).ifPresent(t -> {
//                         value.setWarrantyProductMaxExpiredTime(t.getExpiredTime());
//                     }
//             );
//         });
//     }
//
//     /**
//      * 组装工单跟单数据
//      */
//     private void processOrderTrack(Map<Long, List<OrderTrack>> orderWorkTrackGroupMap,
//                                    Map<Long, EsOrderWork> esOrderWorkMap) {
//         esOrderWorkMap.forEach((key, value) -> {
//
//             List<OrderTrack> trackList = orderWorkTrackGroupMap.get(value.getId());
//             if (CollectionUtils.isEmpty(trackList)) {
//                 return;
//             }
//
//             List<EsOrderWorkTrack> esOrderTrackList = Lists.newArrayListWithCapacity(trackList.size());
//
//             // 跟单操作
//             Optional<OrderTrack> first = trackList.stream().sorted(Comparator.comparing(OrderTrack::getCreateTime).reversed()).findFirst();
//             if (first.isPresent()) {
//                 List<EsOrderWorkOperate> operateList = value.getOperateList();
//                 Integer completeUserId = first.get().getCompleteUserId();
//                 operateList.add(new EsOrderWorkOperate((long)completeUserId, OrderConsts.ORDER_OP_TYPE_TRACK));
//             }
//
//             trackList.forEach((track) -> {
//                 EsOrderWorkTrack orderWorkTrack = new EsOrderWorkTrack();
//                 orderWorkTrack.setTrackId(track.getTrackId());
//                 orderWorkTrack.setTrackTypeId(track.getMapId());
//                 orderWorkTrack.setTrackTypeName(track.getMapName());
//                 orderWorkTrack.setTrackLevel(track.getLevel());
//                 orderWorkTrack.setIsComplete(Objects.equals(GlobalConsts.YES, track.getComplete()));
//                 orderWorkTrack.setResultContent(track.getResultContent());
//                 orderWorkTrack.setRemark(track.getRemark());
//                 esOrderTrackList.add(orderWorkTrack);
//             });
//             value.setTrackList(esOrderTrackList);
//         });
//     }
//
//     /**
//      * 组装订单优惠
//      *
//      * @param orderDiscountGroupMap 工单优惠分组
//      * @param esOrderWorkMap        es order map
//      */
//     private void processOrderDiscount(Map<Long, List<OrderDiscount>> orderDiscountGroupMap,
//                                       Map<Long, EsOrderWork> esOrderWorkMap) {
//         esOrderWorkMap.forEach((key, value) -> {
//
//             List<OrderDiscount> discountList = orderDiscountGroupMap.get(value.getId());
//             if (discountList == null) {
//                 return;
//             }
//             List<EsOrderWorkDiscount> esOrderWorkDiscountList = Lists.newArrayList();
//
//             discountList.forEach((discount) -> {
//                 EsOrderWorkDiscount orderWorkDiscount = new EsOrderWorkDiscount();
//                 orderWorkDiscount.setDiscountCateg(discount.getCateg());
//                 orderWorkDiscount.setDiscountCategName(FicoConsts.getDiscountCategName(discount.getCateg()));
//                 orderWorkDiscount.setDiscountType(discount.getType());
//                 orderWorkDiscount.setDiscountTypeName(OrderConsts.getDiscountTypeName(discount.getType()));
//                 orderWorkDiscount.setDiscountTypeDesc(discount.getTypeDesc());
//                 orderWorkDiscount.setDiscountAmount(discount.getAmount());
//                 orderWorkDiscount.setItemId(discount.getItemId());
//                 orderWorkDiscount.setSourceId(discount.getSourceId());
//                 orderWorkDiscount.setSourceData(discount.getSourceData());
//                 esOrderWorkDiscountList.add(orderWorkDiscount);
//                 if (Objects.equals(GlobalConsts.YES, discount.getThirdCode()) && StringUtil.isNotBlank(discount.getRemark())) {
//                     String couponCode = discount.getRemark().replace("券号 ", "");
//                     value.setCouponCode(couponCode);
//                 }
//
//             });
//             value.setDiscountList(esOrderWorkDiscountList);
//         });
//     }
//
//     /**
//      * 组装工单服务项目
//      *
//      * @param orderWorkServiceItemGroupMap 服务项分组map
//      * @param esOrderWorkMap               es order map
//      */
//     private void processOrderServiceItem(
//             Map<Long, List<OrderServiceItem>> orderWorkServiceItemGroupMap,
//             Map<Long, EsOrderWork> esOrderWorkMap) {
//         esOrderWorkMap.forEach((key, value) -> {
//
//             List<OrderServiceItem> serviceItemList = orderWorkServiceItemGroupMap.get(value.getId());
//             if (serviceItemList == null) {
//                 return;
//             }
//             List<EsOrderWorkServiceItem> esOrderWorkProductList = Lists.newArrayList();
//
//             serviceItemList.forEach((serviceItem) -> {
//                 EsOrderWorkServiceItem orderWorkServiceItem = new EsOrderWorkServiceItem();
//                 orderWorkServiceItem.setProductId(serviceItem.getProductId());
//                 orderWorkServiceItem.setProductName(serviceItem.getProductName());
//                 orderWorkServiceItem.setServiceItemId(serviceItem.getServItemId());
//                 orderWorkServiceItem.setServiceItemName(serviceItem.getServItemName());
//                 orderWorkServiceItem.setServiceItemGroupId(serviceItem.getServItemGroupId());
//                 orderWorkServiceItem.setServiceItemGroupName(serviceItem.getServItemGroupName());
//                 orderWorkServiceItem.setCount(serviceItem.getNumber());
//                 orderWorkServiceItem.setPrice(serviceItem.getItemPrice());
//                 orderWorkServiceItem.setTotalPrice(serviceItem.getTotalPrice());
//                 esOrderWorkProductList.add(orderWorkServiceItem);
//             });
//             value.setServiceItemList(esOrderWorkProductList);
//         });
//     }
//
//     /**
//      * 组装工单产品数据
//      *
//      * @param orderProductGroupMap 工单产品分组map
//      * @param esOrderWorkMap       es order map
//      */
//     private void processOrderProduct(Map<Long, List<OrderProduct>> orderProductGroupMap,
//                                      Map<Long, EsOrderWork> esOrderWorkMap) {
//
//         esOrderWorkMap.forEach((orderId, esOrderWork) -> {
//
//             List<OrderProduct> productList = orderProductGroupMap.get(esOrderWork.getOrderId());
//             if (!CollectionUtils.isEmpty(productList)) {
//                 List<EsOrderWorkProduct> esOrderWorkProductList = Lists.newArrayListWithCapacity(productList.size());
//
//                 productList.forEach((product) -> {
//                     if (Objects.equals(esOrderWork.getProductId(), product.getProductId())) {
//                         esOrderWork.setBrandId(product.getBrandId());
//                         esOrderWork.setCategOneName(product.getCategOneName());
//                         esOrderWork.setCategTwoName(product.getCategName());
//                         esOrderWork.setShowCategOneName(product.getShowCategOneName());
//                         esOrderWork.setShowCategTwoName(product.getShowCategName());
//                     }
//
//                     EsOrderWorkProduct orderWorkProduct = new EsOrderWorkProduct();
//                     orderWorkProduct.setWorkProductId(product.getProId());
//                     orderWorkProduct.setProductId(product.getProductId());
//                     orderWorkProduct.setProductName(product.getProductName());
//                     orderWorkProduct.setProductUnit(product.getProductUnit());
//                     orderWorkProduct.setShowProductId(product.getShowProductId());
//                     orderWorkProduct.setShowProductName(product.getShowProductName());
//                     orderWorkProduct.setShowProductUnit(product.getShowProductUnit());
//                     orderWorkProduct.setBrandId(product.getBrandId());
//                     orderWorkProduct.setNumber(product.getNumber());
//                     orderWorkProduct.setBrandName(product.getBrandName());
//
//                     String fault = null;
//                     if (StringUtils.isNotBlank(product.getFault())) {
//                         try {
//                             List<MapDTO> faultList = JSON.parseArray(product.getFault(), MapDTO.class);
//                             fault = StringUtils.join(Optional.ofNullable(faultList).orElse(Lists.newArrayListWithCapacity(0)).stream().map(MapDTO::getMapName).collect(Collectors.toList()), "，");
//                         } catch (Exception ex) {}
//                     }
//                     orderWorkProduct.setFaultContent(String.format("%s %s", StringUtils.defaultString(fault), StringUtils.defaultString(product.getRemark())));
//                     esOrderWorkProductList.add(orderWorkProduct);
//                 });
//                 esOrderWork.setProductList(esOrderWorkProductList);
//             }
//         });
//     }
//
//     /**
//      * 组装工单工程师数据
//      *
//      * @param orderWorkMasterGroupMap 工单工程师分组map
//      * @param esOrderWorkMap          es order map
//      */
//     private void processOrderMaster(Map<Long, List<OrderMaster>> orderWorkMasterGroupMap,
//                                     Map<Long, EsOrderWork> esOrderWorkMap) {
//
//         orderWorkMasterGroupMap.forEach((workId, masterList) -> {
//
//             EsOrderWork esOrderWork = esOrderWorkMap.get(workId);
//             if (esOrderWork == null) {
//                 return;
//             }
//
//             List<EsOrderWorkMaster> esOrderWorkMasterList = Lists.newArrayListWithCapacity(masterList.size());
//             masterList.forEach((master) -> {
//
//                 // 主工程师处理
//                 if (Objects.equals(master.getType(), OrderConsts.ORDER_MASTER_TYPE_MAIN)) {
//                     esOrderWork.setMasterName(master.getMasterName());
//                     esOrderWork.setMasterPhone(master.getMasterPhone());
//                 }
//
//                 EsOrderWorkMaster esOrderWorkMaster = new EsOrderWorkMaster();
//                 esOrderWorkMaster.setMasterId(master.getMasterId());
//                 esOrderWorkMaster.setMasterName(master.getMasterName());
//                 esOrderWorkMaster.setMasterPhone(master.getMasterPhone());
//                 esOrderWorkMaster.setStarLevel(master.getStarLevel());
//                 esOrderWorkMaster.setMasterType(master.getType());
//                 esOrderWorkMasterList.add(esOrderWorkMaster);
//             });
//             esOrderWork.setMasterList(esOrderWorkMasterList);
//         });
//     }
//
//     /**
//      * 组装会员订单数据
//      *  @param orderMemberMap 会员订单
//      * @param orderDiscountGroupMap
//      * @param esOrderWorkMap es order map
//      */
//     private void processOrderMember(Map<Long, OrderMember> orderMemberMap,
//                                     Map<Long, List<OrderDiscount>> orderDiscountGroupMap,
//                                     Map<Long, EsOrderWork> esOrderWorkMap) {
//         esOrderWorkMap.forEach((key, value) -> {
//             OrderMember orderMember = orderMemberMap.get(value.getOrderId());
//             if (orderMember == null) {
//                 return;
//             }
//
//             EsOrderWorkMember esOrderWorkMember = new EsOrderWorkMember();
//             esOrderWorkMember.setMemberId(orderMember.getMemberId());
//             esOrderWorkMember.setMasterReviewTime(orderMember.getMasterReviewTime());
//             esOrderWorkMember.setPlatReviewTime(orderMember.getPlatReviewTime());
//             esOrderWorkMember.setReviewStatus(orderMember.getReviewStatus());
//             esOrderWorkMember.setSalesPersonId(orderMember.getSalesPersonId());
//             value.setMemberOrder(esOrderWorkMember);
//         });
//     }
//
//     /**
//      * 组装订单扩展数据
//      *
//      * @param orderDetailMap 订单扩展map
//      * @param esOrderWorkMap es order map
//      */
//     private void processOrderDetailList(Map<Long, EsOrderDetailVO> orderDetailMap,
//                                         Map<Long, EsOrderWork> esOrderWorkMap) {
//         esOrderWorkMap.forEach((key, value) -> {
//
//             Long orderId = value.getOrderId();
//
//             if (!orderDetailMap.containsKey(orderId)) {
//                 logger.error("#orderchange# order {} not found orderdetail", orderId);
//                 return;
//             }
//
//             EsOrderDetailVO esOrderDetailVO = orderDetailMap.get(orderId);
//
//             // 扩展数据
//             value.setInScopeService(Objects.equals(esOrderDetailVO.getInScopeService(), GlobalConsts.YES));
//             value.setServCategId(esOrderDetailVO.getServCategId());
//             value.setServCategName(esOrderDetailVO.getServCategName());
//             value.setCategOneId(esOrderDetailVO.getCategOneId());
//             value.setCategTwoId(esOrderDetailVO.getCategId());
//             value.setProductGroupId(esOrderDetailVO.getProductGroupId());
//             value.setProductGroupName(esOrderDetailVO.getProductGroupName());
//             value.setProductId(esOrderDetailVO.getProductId());
//             value.setProductInfo(esOrderDetailVO.getProductInfo());
//             if (StringUtil.isNotBlank(esOrderDetailVO.getFault())) {
//                 value.setFaultContent(esOrderDetailVO.getFault());
//             }
//
//             value.setCountyId(esOrderDetailVO.getCountyId());
//             value.setCountyName(esOrderDetailVO.getCountyName());
//             value.setGridId(esOrderDetailVO.getGridId());
//             value.setGridName(esOrderDetailVO.getGridName());
//             value.setGridCompanyId(esOrderDetailVO.getGridCompanyId());
//             value.setGridCompanyName(esOrderDetailVO.getGridCompanyName());
//             value.setGridManageCompanyId(esOrderDetailVO.getGridManageCompanyId());
//             value.setGridManageCompanyName(esOrderDetailVO.getGridManageCompanyName());
//             value.setCityName(esOrderDetailVO.getCityName());
//             value.setProvinceId(esOrderDetailVO.getProvinceId());
//             value.setProvinceName(esOrderDetailVO.getProvinceName());
//             value.setNaturalCityName(esOrderDetailVO.getNaturalCityName());
//             value.setUserType(esOrderDetailVO.getUserType());
//             value.setVvip(esOrderDetailVO.getVvip());
//             value.setRemark(esOrderDetailVO.getRemark());
//
//             // 2.contact
//             EsOrderWorkContact orderWorkConcat = new EsOrderWorkContact();
//             orderWorkConcat.setUserName(esOrderDetailVO.getUserName());
//             orderWorkConcat.setContactName(esOrderDetailVO.getContactName());
//             orderWorkConcat.setOuterUserId(esOrderDetailVO.getOuterUserId());
//
//             // 2.1 手机号
//             int end4 = 4;
//
//             List<String> phoneList = Lists.newArrayList();
//             List<String> queryPhoneList = Lists.newArrayList();
//             List<String> phoneEnd4List = Lists.newArrayList();
//             phoneList.add(esOrderDetailVO.getTelephone());
//             queryPhoneList.add(esOrderDetailVO.getQueryTelephone());
//             phoneEnd4List.add(StringUtil.cutEnd(esOrderDetailVO.getQueryTelephone(), end4));
//
//             if (StringUtil.isNotBlank(esOrderDetailVO.getTelephone2())) {
//                 phoneList.add(esOrderDetailVO.getTelephone2());
//                 queryPhoneList.add(esOrderDetailVO.getQueryTelephone2());
//                 phoneEnd4List.add(StringUtil.cutEnd(esOrderDetailVO.getQueryTelephone2(), end4));
//             }
//
//             if (StringUtil.isNotBlank(esOrderDetailVO.getTelephone3())) {
//                 phoneList.add(esOrderDetailVO.getTelephone3());
//                 queryPhoneList.add(esOrderDetailVO.getQueryTelephone3());
//                 phoneEnd4List.add(StringUtil.cutEnd(esOrderDetailVO.getQueryTelephone3(), end4));
//             }
//             // 2.2 小号
//             List<String> bindPhoneList = Lists.newArrayList();
//             List<String> bindPhoneEnd4List = Lists.newArrayList();
//             if (StringUtil.isNotBlank(esOrderDetailVO.getBindTelephone())) {
//                 bindPhoneList.add(esOrderDetailVO.getBindTelephone());
//                 bindPhoneEnd4List.add(StringUtil.cutEnd(esOrderDetailVO.getBindTelephone(), end4));
//             }
//             if (StringUtil.isNotBlank(esOrderDetailVO.getBindTelephone2())) {
//                 bindPhoneList.add(esOrderDetailVO.getBindTelephone2());
//                 bindPhoneEnd4List.add(StringUtil.cutEnd(esOrderDetailVO.getBindTelephone2(), end4));
//             }
//             if (StringUtil.isNotBlank(esOrderDetailVO.getBindTelephone3())) {
//                 bindPhoneList.add(esOrderDetailVO.getBindTelephone3());
//                 bindPhoneEnd4List.add(StringUtil.cutEnd(esOrderDetailVO.getBindTelephone3(), end4));
//             }
//
//             orderWorkConcat.setPhone(phoneList.toArray(new String[phoneList.size()]));
//             orderWorkConcat.setQueryPhone(queryPhoneList.toArray(new String[queryPhoneList.size()]));
//             orderWorkConcat.setPhoneEnd4(phoneEnd4List.toArray(new String[phoneEnd4List.size()]));
//             orderWorkConcat.setBindPhone(bindPhoneList.toArray(new String[bindPhoneList.size()]));
//             orderWorkConcat.setBindPhoneEnd4(bindPhoneEnd4List.toArray(new String[bindPhoneEnd4List.size()]));
//             orderWorkConcat.setBindStatus(esOrderDetailVO.getBindStatus());
//             orderWorkConcat.setStreet(esOrderDetailVO.getStreet());
//             orderWorkConcat.setStreetSource(esOrderDetailVO.getStreetSource());
//             orderWorkConcat.setStreetId(esOrderDetailVO.getStreetId());
//             orderWorkConcat.setAddress(StringUtils.defaultString(esOrderDetailVO.getAddress()).replace(" ", ""));
//             orderWorkConcat.setQueryAddress(esOrderDetailVO.getQueryAddress());
//             orderWorkConcat.setFullAddress(esOrderDetailVO.getFullAddress());
//             orderWorkConcat.setQueryFullAddress(esOrderDetailVO.getQueryFullAddress());
//             orderWorkConcat.setGender(esOrderDetailVO.getGender());
//             if (esOrderDetailVO.getLatitude() != null && esOrderDetailVO.getLongitude() != null) {
//                 orderWorkConcat.setLocation(String.format("%s,%s", esOrderDetailVO.getLatitude(), esOrderDetailVO.getLongitude()));
//                 // 地理形状类型
//                 EsGeoShape esGeoShape = EsGeoShape.builder()
//                         .type("point")
//                         .coordinates(new Double[]{esOrderDetailVO.getLongitude(), esOrderDetailVO.getLatitude()})
//                         .build();
//                 orderWorkConcat.setLocationShape(esGeoShape);
//             }
//             value.setContact(orderWorkConcat);
//         });
//     }
//
//     /**
//      * 处理工单列表
//      *
//      * @param orderWorkMap   工单list
//      * @param esOrderWorkMap es orderwork map
//      */
//     private void processOrderWorkList(Map<Long, OrderWork> orderWorkMap, Map<Long, EsOrderWork> esOrderWorkMap) {
//
//         // es模型设置返修工程师姓名、电话（因工单表中没存，需调用dubbo查询）
//         List<Integer> masterIdList = orderWorkMap.values().stream().filter(e -> !NumberUtil.isNullOrZero(e.getReworkMasterId())).map(e -> e.getReworkMasterId()).distinct().collect(Collectors.toList());
//         Map<Integer, String> masterNameMaps = Maps.newHashMap();
//         Map<Integer, String> masterPhoneMaps = Maps.newHashMap();
//         if (masterIdList != null && masterIdList.size() != 0) {
//             ResponseDTO<List<BaseEngineerDRO>> responseDTO = engineerListRemoteService.listEngineerByEngineerIdList(new HashSet<>(masterIdList), null);
//             if (responseDTO.isSuccess() && !CollectionUtils.isEmpty(responseDTO.getData())) {
//                 List<BaseEngineerDRO> items = responseDTO.getData();
//                 masterNameMaps = items.stream().collect(Collectors.toMap(BaseEngineerDRO::getMasterId, BaseEngineerDRO::getRealname, (entity1, entity2) -> entity1));
//                 masterPhoneMaps = items.stream().collect(Collectors.toMap(BaseEngineerDRO::getMasterId, BaseEngineerDRO::getMobile, (entity1, entity2) -> entity1));
//             }
//         }
//
//         final Map<Integer, String> masterNameMap = masterNameMaps;
//         final Map<Integer, String> masterPhoneMap = masterPhoneMaps;
//
//         orderWorkMap.forEach((key, value) -> {
//             EsOrderWork esOrderWork = new EsOrderWork();
//             esOrderWork.setId(value.getWorkId());
//             esOrderWork.setOrderId(value.getOrderId());
//             esOrderWork.setPlat(value.getPlat());
//             esOrderWork.setPlatWork(value.getPlatWork());
//             esOrderWork.setCompanyId(value.getCompanyId());
//             esOrderWork.setCompanyName(value.getCompanyName());
//             esOrderWork.setManageCompanyId(value.getManageCompanyId());
//             esOrderWork.setManageCompanyName(value.getManageCompanyName());
//             esOrderWork.setManageCompanyType(value.getManageCompanyType());
//
//             esOrderWork.setOrgOneId(value.getOrgOneId());
//             esOrderWork.setOrgTwoId(value.getOrgTwoId());
//             esOrderWork.setOrgThreeId(value.getOrgThreeId());
//             esOrderWork.setOrgFourId(value.getOrgFourId());
//             esOrderWork.setChannelOneId(value.getChannelOneId());
//             esOrderWork.setChannelTwoId(value.getChannelTwoId());
//
//             esOrderWork.setChannelId(value.getChannelId());
//             esOrderWork.setChannelTypeId(value.getChannelTypeId());
//             esOrderWork.setChannelName(value.getChannelName());
//             if (Objects.equals(value.getSourceChannelId(), 0)) {
//                 esOrderWork.setSourceChannelId(value.getChannelId());
//                 esOrderWork.setSourceChannelOneId(value.getChannelOneId());
//                 esOrderWork.setSourceChannelTwoId(value.getChannelTwoId());
//             } else {
//                 esOrderWork.setSourceChannelId(value.getSourceChannelId());
//                 esOrderWork.setSourceChannelOneId(value.getSourceChannelOneId());
//                 esOrderWork.setSourceChannelTwoId(value.getSourceChannelTwoId());
//             }
//             esOrderWork.setCodeEnd6(StringUtil.cutEnd(value.getWorkId().toString(), 6));
//             esOrderWork.setStatus(value.getStatus());
//             esOrderWork.setResultStatus(value.getResultStatus());
//             esOrderWork.setOuterId(value.getOuterId());
//             esOrderWork.setReworkId(value.getReworkId());
//             esOrderWork.setReworkMasterId(value.getReworkMasterId());
//             esOrderWork.setChannelStatementStatus(GlobalConsts.NO);
//             esOrderWork.setTimeoutPayCancel(GlobalConsts.NONE);
//             String reworkMasterName;
//             String reworkMasterPhone;
//             if (masterNameMap != null) {
//                 reworkMasterName = masterNameMap.get(value.getReworkMasterId());
//                 reworkMasterPhone =  masterPhoneMap.get(value.getReworkMasterId());
//             } else {
//                 reworkMasterName = "";
//                 reworkMasterPhone = "";
//             }
//             esOrderWork.setReworkMasterName(reworkMasterName);
//             esOrderWork.setReworkMasterPhone(reworkMasterPhone);
//             esOrderWork.setOriginalId(value.getOriginalId());
//             esOrderWork.setOriginalCodeEnd6(StringUtil.cutEnd(value.getOriginalId().toString(), 6));
//             esOrderWork.setReworkCodeEnd6(StringUtil.cutEnd(value.getReworkId().toString(), 6));
//             esOrderWork.setCodeEnd6(StringUtil.cutEnd(value.getWorkId().toString(), 6));
//             esOrderWork.setType(value.getType());
//             esOrderWork.setGrabType(value.getGrabType());
//             esOrderWork.setPayStatus(value.getPayStatus());
//             esOrderWork.setDepositStatus(value.getDepositStatus());
//             esOrderWork.setPrepayStatus(value.getPrepayStatus());
//             esOrderWork.setChannelPrepayStatus(value.getChannelPrepayStatus());
//             esOrderWork.setPartReimburseStatus(value.getPartReimburseStatus());
//             esOrderWork.setPartReimburseTime(value.getPartReimburseTime());
//             esOrderWork.setTrackStatus(value.getTrackStatus());
//             esOrderWork.setAppliqueStatus(value.getAppliqueStatus());
//             esOrderWork.setMasterImageStatus(value.getMasterImageStatus());
//             esOrderWork.setVisitOnTimeStatus(GlobalConsts.NONE);
//             esOrderWork.setAmountReviewStatus(value.getAmountReviewStatus());
//             esOrderWork.setAmountReviewStatusName(OrderConsts.getReviewStatusName(value.getAmountReviewStatus()));
//             esOrderWork.setRefundReviewStatus(value.getRefundReviewStatus());
//             esOrderWork.setBizLine(value.getBizLine());
//             esOrderWork.setServProductGroupId(value.getServProductGroupId());
//             esOrderWork.setServProductGroupName(value.getServProductGroupName());
//             esOrderWork.setShowProductGroupId(value.getShowProductGroupId());
//             esOrderWork.setShowProductGroupName(value.getShowProductGroupName());
//             esOrderWork.setShowCategOneId(value.getShowCategOneId());
//             esOrderWork.setShowCategTwoId(value.getShowCategId());
//             esOrderWork.setShowProductId(value.getShowProductId());
//             esOrderWork.setShowServCategName(value.getShowServCategName());
//             esOrderWork.setDutyStatus(value.getDutyStatus() == null ? OrderDutyConsts.DUTY_STATUS_NONE : value.getDutyStatus());
//             esOrderWork.setDutyFailCode(value.getDutyFailCode());
//             esOrderWork.setSubWeixincp(GlobalConsts.NO);
//             esOrderWork.setBizType(value.getBizType());
//             esOrderWork.setBizMode(value.getBizMode());
//             esOrderWork.setBizModeSource(value.getBizModeSource());
//             esOrderWork.setRefundWorkId(value.getRefundWorkId());
//             esOrderWork.setRefundTargetWorkId(value.getRefundTargetWorkId());
//             esOrderWork.setDistributeWay(value.getDistributeWay());
//             // bool 相关
//             esOrderWork.setIsReply(value.getReplyVisitTime() != null);
//             esOrderWork.setHasDelivery(Objects.equals(value.getDelivery(), GlobalConsts.YES));
//             esOrderWork.setHasWaitPart(Objects.equals(value.getWaitPart(), GlobalConsts.YES));
//             esOrderWork.setIsOnlyVisit(Objects.equals(value.getOnlyVisit(), GlobalConsts.YES));
//             esOrderWork.setIsTest(Objects.equals(value.getTest(), GlobalConsts.YES));
//             esOrderWork.setIsDuplicate(Objects.equals(value.getDuplicate(), GlobalConsts.YES));
//             esOrderWork.setSourceType(value.getSourceType());
//             esOrderWork.setIsMultiMaster(Objects.equals(value.getMultiMaster(), GlobalConsts.YES));
//             esOrderWork.setIsDefaultComment(false);
//             esOrderWork.setServItemType(Optional.ofNullable(value.getServItemType()).orElse(OrderConsts.SERVICE_ITEM_TYPE_ORDER));
//
//             Boolean hasChannelPrepayAmount = value.getChannelPrepayAmount() != null && Objects.equals(PayConsts.PAY_STATUS_DONE, value.getChannelPrepayStatus());
//             esOrderWork.setHasChannelPrepayAmount(hasChannelPrepayAmount);
//             Boolean hasDepositAmount = value.getDepositAmount() != null && Objects.equals(PayConsts.PAY_STATUS_DONE, value.getDepositStatus());
//             esOrderWork.setHasDeposit(hasDepositAmount);
//             esOrderWork.setComplaintStatus(value.getComplaintStatus());
//             esOrderWork.setAbnormalStatus(value.getAbnormalStatus());
//             esOrderWork.setIsStandardPrice(Objects.equals(value.getStandardPrice(), GlobalConsts.YES));
//             esOrderWork.setIsMember(Objects.equals(value.getMember(), GlobalConsts.YES));
//             esOrderWork.setIsFinalPrice(Objects.equals(value.getFinalPrice(), GlobalConsts.YES));
//             esOrderWork.setIsDisableDiscard(Objects.equals(value.getDisableDiscard(), GlobalConsts.YES));
//             int partAmountSum = Optional.ofNullable(value.getPartAmount()).orElse(0) +
//                     Optional.ofNullable(value.getInSourcingAmount()).orElse(0) +
//                     Optional.ofNullable(value.getOutSourcingAmount()).orElse(0) +
//                     Optional.ofNullable(value.getDeliverAmount()).orElse(0) +
//                     Optional.ofNullable(value.getFactoryPartAmount()).orElse(0);
//             esOrderWork.setHasPart(partAmountSum > 0);
//
//             // 完成人
//             esOrderWork.setCompleterId(value.getCompleterId());
//
//             // 时间相关
//             esOrderWork.setInputTime(value.getCreateTime());
//             esOrderWork.setReceiveTime(value.getReceiveTime());
//             esOrderWork.setTurnTime(value.getTurnTime());
//             esOrderWork.setAssignTime(value.getAssignTime());
//             esOrderWork.setAssignConfirmTime(value.getAssignConfirmTime());
//             esOrderWork.setContactTime(value.getContactTime());
//             esOrderWork.setConfirmTime(value.getConfirmTime());
//             esOrderWork.setDutyTime(value.getDutyTime());
//             esOrderWork.setSuspendTime(value.getSuspendTime());
//             esOrderWork.setDistributeTime(value.getDistributeTime());
//             esOrderWork.setPayTime(value.getPayTime());
//             esOrderWork.setCompleteTime(value.getCompleteTime());
//             esOrderWork.setCheckoutTime(value.getCheckoutTime());
//             esOrderWork.setAccountTime(value.getAccountTime());
//             esOrderWork.setReplyVisitTime(value.getReplyVisitTime());
//             esOrderWork.setVisitTime(value.getVisitTime());
//             esOrderWork.setResultTime(value.getResultTime());
//             esOrderWork.setCancelTime(value.getCancelTime());
//             esOrderWork.setTakeTime(value.getTakeTime());
//             esOrderWork.setLastRefundAmountTime(value.getRefundTime()); // 退款时间
//             esOrderWork.setDepositTime(value.getDepositTime());
//             esOrderWork.setNextContactTime(value.getNextContactTime());
//             // 服务完成
//             esOrderWork.setServiceCompleteTime(value.getServiceCompleteTime());
//             esOrderWork.setServiceCompleteReviewerId(value.getServiceCompleteReviewerId());
//             esOrderWork.setServiceCompleteReviewStatus(value.getServiceCompleteReviewStatus());
//             esOrderWork.setServiceCompleteReviewTime(value.getServiceCompleteReviewTime());
//
//             // 金额相关
//             esOrderWork.setOriginalAmount(value.getOriginalAmount());
//             esOrderWork.setTotalAmount(value.getTotalAmount());
//             esOrderWork.setChannelPrepayAmount(value.getChannelPrepayAmount());
//             esOrderWork.setMasterAmount(value.getMasterAmount());
//             esOrderWork.setDiscountAmount(value.getDiscountAmount());
//             esOrderWork.setDepositAmount(value.getDepositAmount());
//             esOrderWork.setChannelAmount(value.getChannelAmount());
//             esOrderWork.setChannelSettleStatus(value.getChannelSettleStatus());
//             esOrderWork.setRefundAmount(value.getRefundAmount());
//             esOrderWork.setPartAmount(value.getPartAmount());
//             esOrderWork.setInSourcingPartAmount(value.getInSourcingAmount());
//             esOrderWork.setOutSourcingPartAmount(value.getOutSourcingAmount());
//             esOrderWork.setDeliverAmount(value.getDeliverAmount());
//             esOrderWork.setPartReimburseAmount(value.getPartReimburseAmount());
//             esOrderWork.setPartRetain(value.getPartRetain());
//             esOrderWork.setBillAmount(value.getBillAmount());
//             esOrderWork.setSubsidyAmount(value.getSubsidyAmount());
//             esOrderWork.setPrepayAmount(value.getPrepayAmount());
//
//             // status name / type name
//             esOrderWork.setTypeName(OrderConsts.getOrderTypeName(value.getType()));
//             esOrderWork.setStatusName(OrderStatusConsts.getWorkStatusName(value.getStatus()));
//             esOrderWork.setResultStatusName(OrderStatusConsts.getWorkResultStatusName(value.getResultStatus()));
//             esOrderWork.setPayStatusName(PayConsts.getPayStatusName(value.getPayStatus()));
//             esOrderWork.setDepositChannelId(value.getDepositChannelId());
//             esOrderWork.setMasterPayChannelId(value.getMasterPayChannelId());
//             esOrderWork.setPrepayChannelId(value.getPrepayChannelId());
//             esOrderWork.setPrepayChannelName(GlobalConsts.getPayChannelName(value.getPrepayChannelId()));
//
//             // 服务审核
//             esOrderWork.setServiceCompleteReviewerId(value.getServiceCompleteReviewerId());
//             esOrderWork.setServiceCompleteReviewStatus(value.getServiceCompleteReviewStatus());
//             esOrderWork.setServiceCompleteReviewTime(value.getServiceCompleteReviewTime());
//
//             // other
//             esOrderWork.setMasterId(value.getMasterId());
//             esOrderWork.setCityId(value.getCityId());
//             esOrderWork.setNaturalCityId(value.getNaturalCityId());
//             esOrderWork.setCurrentRemark(value.getCurrentRemark());
//             esOrderWork.setUserId(value.getUserId());
//             esOrderWork.setVisitUserId(value.getVisitUserId());
//             esOrderWork.setCustomerId(value.getCustomerId());
//
//             // 工程师主管信息
//             esOrderWork.setMasterSupervisorId(value.getMasterSupervisorId());
//             esOrderWork.setMasterSupervisorName(value.getMasterSupervisorName());
//             esOrderWork.setMasterSupervisorPhone(value.getMasterSupervisorPhone());
//             // old
//             esOrderWork.setOldId(value.getOldId());
//             esOrderWork.setOldCode(value.getOldCode());
//
//             // 工单操作
//             ArrayList<EsOrderWorkOperate> operateList = Lists.newArrayListWithCapacity(15);
//             Long receiverId = value.getReceiverId();
//             operateList.add(new EsOrderWorkOperate(receiverId, OrderConsts.ORDER_OP_TYPE_INPUT));
//
//             Long confirmerId = value.getConfirmerId();
//             if (confirmerId != null) {
//                 operateList.add(new EsOrderWorkOperate(confirmerId, OrderConsts.ORDER_OP_TYPE_CONFIRM));
//             }
//             Long distributerId = value.getDistributerId();
//             if (distributerId != null) {
//                 operateList.add(new EsOrderWorkOperate(distributerId, OrderConsts.ORDER_OP_TYPE_DISTRIBUTE));
//             }
//             Long checkouterId = value.getCheckouterId();
//             if (checkouterId != null) {
//                 operateList.add(new EsOrderWorkOperate(checkouterId, OrderConsts.ORDER_OP_TYPE_CHECKOUT));
//             }
//             Long accounterId = value.getAccounterId();
//             if (accounterId != null) {
//                 operateList.add(new EsOrderWorkOperate(accounterId, OrderConsts.ORDER_OP_TYPE_ACCOUNT));
//             }
//             Long replyVisiterId = value.getReplyVisiterId();
//             if (replyVisiterId != null) {
//                 operateList.add(new EsOrderWorkOperate(replyVisiterId, OrderConsts.ORDER_OP_TYPE_REPLY_VISIT));
//             }
//             Long turnerId = value.getTurnerId();
//             if (turnerId != null) {
//                 operateList.add(new EsOrderWorkOperate(turnerId, OrderConsts.ORDER_OP_TYPE_TURN));
//             }
//
//             // 操作人
//             esOrderWork.setReceiverId(receiverId);
//             esOrderWork.setConfirmerId(confirmerId);
//             esOrderWork.setTurnerId(turnerId);
//             esOrderWork.setAssignerId(value.getAssignerId());
//             esOrderWork.setDistributerId(value.getDistributerId());
//             esOrderWork.setCheckouterId(value.getCheckouterId());
//             esOrderWork.setAccounterId(value.getAccounterId());
//             esOrderWork.setReplyVisiterId(value.getReplyVisiterId());
//
//             esOrderWork.setResulterId(value.getResulterId());
//             esOrderWork.setResulterType(value.getResulterType());
//             esOrderWork.setCancelerId(value.getCancelerId());
//             esOrderWork.setCancelerType(value.getCancelerType());
//
//             esOrderWork.setReceiverType(value.getReceiverType());
//             esOrderWork.setReceiveEntranceType(value.getReceiveEntranceType());
//             esOrderWork.setReceiveEntranceId(value.getReceiveEntranceId());
//             esOrderWork.setReceiverManner(value.getReceiverManner());
//             esOrderWork.setRecommenderId(value.getRecommenderId());
//             esOrderWork.setRecommenderType(value.getRecommenderType());
//
//             // 取消
//             if (Objects.equals(value.getResultStatus(), OrderStatusConsts.WORK_RESULT_DISCARD)
//             || Objects.equals(value.getResultStatus(), OrderStatusConsts.WORK_RESULT_FAIL)) {
//                 Long resulterId = value.getResulterId();
//                 operateList.add(new EsOrderWorkOperate(resulterId, OrderConsts.ORDER_OP_TYPE_CANCEL));
//             }
//
//             //退款单为：其他报价
//             if (Objects.equals(value.getType(),OrderConsts.ORDER_TYPE_REFUND)) {
//                 esOrderWork.setQuotationType(OrderConsts.ORDER_QUOTATION_TYPE_OTHER);
//                 esOrderWork.setPartakeQuotationTypeList(Arrays.asList(OrderConsts.ORDER_QUOTATION_TYPE_OTHER));
//             }
//
//             esOrderWork.setOperateList(operateList);
//             esOrderWorkMap.put(key, esOrderWork);
//         });
//     }
//
//     /**
//      * 工单凭证
//      * @param voucherOrderMap
//      * @param esOrderWorkMap
//      */
//     private void processVoucherOrder(Map<Long, List<OrderPay>> voucherOrderMap, Map<Long, EsOrderWork> esOrderWorkMap) {
//         esOrderWorkMap.forEach((k, v) ->{
//             List<OrderPay> voucherOrderDROS = voucherOrderMap.get(k);
//             if (!CollectionUtils.isEmpty(voucherOrderDROS)) {
//                 // 存储支付凭证
//                 List<EsVoucherOrder> esVoucherOrders = BeanMapper.mapList(voucherOrderDROS, EsVoucherOrder.class);
//                 v.setVoucherOrderList(esVoucherOrders);
//                 // 啄木鸟预收款
//                 OrderPay prepayOrderDRO = voucherOrderDROS.stream().filter(e -> Objects.equals(OrderPayConsts.ORDER_PAY_PREPAY, e.getAmountType())).findFirst().orElse(null);
//                 if (prepayOrderDRO != null) {
//                     v.setPrepayTradeNo(prepayOrderDRO.getPayOutTradeNo());
//                     v.setPrepayPayType(prepayOrderDRO.getPayType());
//                     v.setPrepayPayTargetChannelId(prepayOrderDRO.getPayTargetChannelId());
//                     v.setPrepayPayTargetType(prepayOrderDRO.getPayTargetType());
//                 }
//
//                 // 定金流水号
//                 OrderPay depositOrderDRO = voucherOrderDROS.stream().filter(e -> Objects.equals(OrderPayConsts.ORDER_PAY_DEPOSIT, e.getAmountType())).findFirst().orElse(null);
//                 if (depositOrderDRO != null) {
//                     v.setDepositTradeNo(depositOrderDRO.getPayOutTradeNo());
//                     v.setDepositPayType(depositOrderDRO.getPayType());
//                     v.setDepositPayTargetChannelId(depositOrderDRO.getPayTargetChannelId());
//                     v.setDepositPayTargetType(depositOrderDRO.getPayTargetType());
//                 }
//
//                 // 工程师收款流水号
//                 OrderPay masterVoucherDRO = voucherOrderDROS.stream().filter(e -> Objects.equals(OrderPayConsts.ORDER_PAY_MASTER, e.getAmountType())).findFirst().orElse(null);
//                 if (masterVoucherDRO != null) {
//                     v.setMasterAmountTradeNo(masterVoucherDRO.getPayOutTradeNo());
//                     v.setPayType(masterVoucherDRO.getPayType());
//                     v.setPayTargetChannelId(masterVoucherDRO.getPayTargetChannelId());
//                     v.setPayTargetType(masterVoucherDRO.getPayTargetType());
//                 }
//             }
//         });
//     }
//
//
//     /**
//      * 添加渠道扩展订单号
//      * @param orderIdList
//      * @param esOrderWorkMap
//      */
//     private void processOrderExtendData(List<Long> orderIdList, List<OrderExtend> orderExtends, Map<Long, EsOrderWork> esOrderWorkMap) {
//         // 渠道扩展信息
//         if (!CollectionUtils.isEmpty(orderExtends)) {
//             for (OrderExtend item : orderExtends) {
//                 EsOrderWork esOrderWork = esOrderWorkMap.get(item.getExtId());
//                 if (esOrderWork == null) {
//                     continue;
//                 }
//
//                 esOrderWork.setWeChatScanUserId(item.getWeChatScanUserId());
//
//                 // 渠道扩展订单号（第二订单号，适用于渠道方存在两级或两级以上订单编号的情况）
//                 if (StringUtils.isNotBlank(item.getExtOuterId())) {
//                     esOrderWork.setExtOuterId(item.getExtOuterId());
//                 }
//                 // 渠道扩展订单号（第三订单号，适用于渠道方存在三级订单编号的情况）
//                 if (StringUtils.isNotBlank(item.getExtOuterSubId())) {
//                     esOrderWork.setExtOuterSubId(item.getExtOuterSubId());
//                 }
//                 // 节能减排量
//                 if (item.getProductsEmission() != null) {
//                     esOrderWork.setProductsEmission(item.getProductsEmission());
//                 }
//                 /*
//                   德施曼订单特殊处理：
//                     德方财务结算时要求我们提供对方的店铺名称（这个数据和我们的订单对接业务没有任何关系），为满足德方财务人员
//                     的合(man)理(heng)要求，添加此字段，用于导出德施曼订单时提供给德方财务结算使用。  lhl-2020.11.18
//                  */
//                 if (Objects.equals(DeshimanConsts.CHANNEL_ID, esOrderWork.getChannelId())
//                         && StringUtils.isNotBlank(item.getExtraData())) {
//                     Matcher matcher = Pattern.compile(".*?\"shopName\":\"(.+?)\"[,|\\}].*?")
//                             .matcher(item.getExtraData());
//                     if (matcher.find()) {
//                         String extraData = String.format("{\"shopName\":\"%s\"}", matcher.group(1));
//                         esOrderWork.setChannelExtraData(extraData);
//                     }
//                 }
//             }
//         }
//
//         // 天猫订单的签收时间和核销时间
//         List<OrderTmallExtend> orderTmallExtends = orderTmallExtendBService.listByOrderIdList(orderIdList);
//         if (!CollectionUtils.isEmpty(orderTmallExtends)) {
//             for (OrderTmallExtend item : orderTmallExtends) {
//                 EsOrderWork esOrderWork = esOrderWorkMap.get(item.getOrderId());
//                 if (esOrderWork == null) {
//                     continue;
//                 }
//                 // 核销时间
//                 Date verificationTime = item.getVerificationTime();
//                 if (verificationTime != null) {
//                     esOrderWork.setVerificationTime(verificationTime);
//                 }
//                 // 签收时间
//                 Date signForTime = item.getSignForTime();
//                 if (signForTime != null) {
//                     esOrderWork.setSignForTime(signForTime);
//                 }
//                 // 签到时间
//                 Date signInTime = item.getSignInTime();
//                 if (signInTime != null) {
//                     esOrderWork.setSignInTime(signInTime);
//                 }
//                 // 签到状态
//                 Integer signInStatus = item.getSignInStatus();
//                 if (signInStatus != null) {
//                     esOrderWork.setSignInStatus(signInStatus);
//                 }
//             }
//         }
//
//         esOrderWorkMap.forEach((orderId, esOrderWork) -> {
//             // 天猫欧派订单，设置产品的品牌为欧派  2020.11.26 by lhl
//             if (Objects.equals(OrderConsts.CHANNEL_ID_TMALL_BIZ_OPPEIN, esOrderWork.getChannelId())) {
//                 esOrderWork.setBrandId(1091);
//                 List<EsOrderWorkProduct> productList = esOrderWork.getProductList();
//                 if (!CollectionUtils.isEmpty(productList)) {
//                     for (EsOrderWorkProduct product : productList) {
//                         product.setBrandId(1091);
//                     }
//                 }
//             }
//         });
//     }
//
//     /**
//      * 订单操作（计价器报价）
//      * @param orderOperationMap
//      * @param esOrderWorkMap
//      */
//     private void processOrderOperation(Map<Long, OrderOperation> orderOperationMap, Map<Long, EsOrderWork> esOrderWorkMap) {
//         orderOperationMap.forEach((orderId, item) -> {
//             EsOrderWork esOrderWork = esOrderWorkMap.get(orderId);
//             if (esOrderWork != null) {
//                 logger.debug("#processOrderOperation# 同步报价人信息 end orderId list : {}", item);
//                 // 报价人类型
//                 esOrderWork.setQuotationType(item.getQuotationType());
//                 // 首次报价人id
//                 esOrderWork.setFirstQuotationId(item.getFirstQuotationId());
//                 // 首次报价人类型
//                 esOrderWork.setFirstQuotationType(item.getFirstQuotationType());
//                 //参与报价人
//                 if (StringUtils.isNotBlank(item.getPartakeQuotationTypes())) {
//                     List<Integer> partakeQuotationTypes = Arrays.asList(item.getPartakeQuotationTypes().split(",")).stream().map(s -> Integer.parseInt(s.trim())).collect(Collectors.toList());
//                     esOrderWork.setPartakeQuotationTypeList(partakeQuotationTypes);
//                 }
//             }
//         });
//     }
//
//     /**
//      * 组装订单备注详情信息
//      *
//      * @param esOrderWorkMap es order map
//      */
//     private void processOrderRemarkDetail(Map<Long, EsOrderWork> esOrderWorkMap, Map<Long, List<OrderRemarkDetail>> remarkDetailMap) {
//         remarkDetailMap.forEach((workId, remarkDetailList) -> {
//             EsOrderWork esOrderWork = esOrderWorkMap.get(workId);
//             if(esOrderWork == null){
//                 return;
//             }
//             esOrderWork.setRemarkDetailList(BeanMapper.mapList(remarkDetailList, EsOrderRemarkDetail.class));
//         });
//     }
//
//     /**
//      * @descript: 组装快递信息
//      * @author: xiaofei
//      * @param: [orderWorkPostGroupMap, esOrderWorkMap]
//      * @return: void
//      * @date: 2020/8/7 13:34
//      * @version: v1.0
//      */
//     private void processOrderPost(Map<Long, List<OrderPost>> orderWorkPostGroupMap, Map<Long, EsOrderWork> esOrderWorkMap) {
//         orderWorkPostGroupMap.forEach((orderId, orderPostList) -> {
//             EsOrderWork esOrderWork = esOrderWorkMap.get(orderId);
//             if(esOrderWork == null){
//                 return;
//             }
//
//             logger.info("同步快递信息orderId:{}",orderId);
//             List<EsOrderPost> esOrderPostList = Lists.newArrayListWithCapacity(orderPostList.size());
//             orderPostList.forEach(orderPost -> {
//                 EsOrderPost esOrderPost = new EsOrderPost();
//                 esOrderPost.setExpressCode(orderPost.getExpressCode());
//                 esOrderPost.setExpressCompanyCode(orderPost.getExpressCompanyCode());
//                 esOrderPost.setItemType(orderPost.getItemType());
//                 esOrderPost.setStatus(orderPost.getStatus());
//                 esOrderPostList.add(esOrderPost);
//             });
//             esOrderWork.setOrderPostList(esOrderPostList);
//         });
//     }
//
//     /**
//      * 工单附件
//      *
//      * @param orderAttachmentMap
//      * @param esOrderWorkMap
//      */
//     private void processOrderAttachment(Map<Long, List<OrderAttachment>> orderAttachmentMap, Map<Long, EsOrderWork> esOrderWorkMap) {
//         orderAttachmentMap.forEach((orderId, orderAttachmentList) -> {
//             EsOrderWork esOrderWork = esOrderWorkMap.get(orderId);
//             if (esOrderWork == null) {
//                 return;
//             }
//             List<EsOrderAttachment> esOrderAttachmentList = Lists.newArrayListWithCapacity(orderAttachmentList.size());
//             orderAttachmentList.forEach(orderAttachment -> {
//                 EsOrderAttachment esorderAttachment = new EsOrderAttachment();
//                 esorderAttachment.setType(orderAttachment.getType());
//                 esorderAttachment.setNeedReview(orderAttachment.getNeedReview());
//                 esorderAttachment.setReviewStatus(orderAttachment.getReviewStatus());
//                 esOrderAttachmentList.add(esorderAttachment);
//             });
//             esOrderWork.setOrderAttachmentList(esOrderAttachmentList);
//         });
//     }
//
//     /**
//      * 组装订单标签
//      * @param orderTagMap
//      * @param esOrderWorkMap
//      */
//     private void processOrderTag(Map<Long, List<OrderTag>> orderTagMap, Map<Long, EsOrderWork> esOrderWorkMap) {
//         orderTagMap.forEach((workId, orderTagList) -> {
//             EsOrderWork esOrderWork = esOrderWorkMap.get(workId);
//             if (esOrderWork == null) {
//                 return;
//             }
//
//             List<EsOrderTag> esOrderTagList = Lists.newArrayListWithCapacity(orderTagList.size());
//             orderTagList.forEach(orderTag -> {
//                 EsOrderTag esOrderTag = new EsOrderTag();
//                 esOrderTag.setTagType(orderTag.getTagType());
//                 esOrderTag.setTagId(orderTag.getTagId());
//                 esOrderTag.setTagName(orderTag.getTagName());
//                 if (StringUtils.isNotBlank(orderTag.getCategoryIds())) {
//                     esOrderTag.setCategoryIdList(Arrays.asList(orderTag.getCategoryIds().split(",")));
//                 }
//                 esOrderTagList.add(esOrderTag);
//             });
//             esOrderWork.setOrderTagList(esOrderTagList);
//         });
//     }
//
//     private void processOrderReview(Map<Long, List<OmsOrderReview>> orderReviewMap, Map<Long, EsOrderWork> esOrderWorkMap) {
//         orderReviewMap.forEach((workId, orderReviewList) -> {
//             EsOrderWork esOrderWork = esOrderWorkMap.get(workId);
//             if(esOrderWork == null){
//                 return;
//             }
//             esOrderWork.setWorkReviewList(BeanMapper.mapList(orderReviewList, EsOrderWorkReview.class));
//         });
//     }
//
//     private void processRefundWorkReviewStatus(Map<Long, List<OmsOrderReview>> orderReviewMap, Map<Long, EsOrderWork> esOrderWorkMap) {
//         esOrderWorkMap.forEach((workId, esOrderWork) -> {
//             List<OmsOrderReview> orderReviews = orderReviewMap.get(workId);
//             if(CollectionUtil.isNullOrEmpty(orderReviews)){
//                 esOrderWork.setRefundWorkReviewStatus(GlobalConsts.NONE);
//                 return;
//             }
//             OmsOrderReview orderRefundReview = orderReviews.stream()
//                     .filter(e -> Objects.equals(e.getReviewType(), OrderConsts.OMS_ORDER_REVIEW_REFUND))
//                     .findFirst()
//                     .orElse(null);
//             if (Objects.isNull(orderRefundReview)) {
//                 esOrderWork.setRefundWorkReviewStatus(GlobalConsts.NONE);
//                 return;
//             }
//             esOrderWork.setRefundWorkReviewStatus(orderRefundReview.getReviewStatus());
//         });
//     }
//
//     /**
//      * 处理订单验收
//      *
//      * @param orderWorkAcceptanceMap
//      * @param esOrderWorkMap
//      */
//     private void processOrderWorkAcceptance(Map<Long, List<OrderWorkAcceptance>> orderWorkAcceptanceMap, Map<Long, EsOrderWork> esOrderWorkMap) {
//         orderWorkAcceptanceMap.forEach((orderId, orderWorkAcceptanceList) -> {
//             EsOrderWork esOrderWork = esOrderWorkMap.get(orderId);
//             if (esOrderWork == null) {
//                 return;
//             }
//
//             List<EsOrderWorkAcceptance> esOrderWorkAcceptanceList = Lists.newArrayListWithCapacity(orderWorkAcceptanceList.size());
//             orderWorkAcceptanceList.forEach(orderWorkAcceptance -> {
//                 EsOrderWorkAcceptance esOrderWorkAcceptance = new EsOrderWorkAcceptance();
//                 esOrderWorkAcceptance.setAcceptanceId(orderWorkAcceptance.getAcceptanceId());
//                 esOrderWorkAcceptance.setAcceptanceType(orderWorkAcceptance.getAcceptanceType());
//                 esOrderWorkAcceptance.setAcceptanceResultStatus(orderWorkAcceptance.getAcceptanceResultStatus());
//                 esOrderWorkAcceptance.setReasonValues(orderWorkAcceptance.getReasonValues());
//                 esOrderWorkAcceptance.setOperatorId(orderWorkAcceptance.getOperatorId());
//                 esOrderWorkAcceptance.setOperatorType(orderWorkAcceptance.getOperatorType());
//                 esOrderWorkAcceptance.setOperatorId(orderWorkAcceptance.getOperatorId());
//                 esOrderWorkAcceptance.setOperateTime(orderWorkAcceptance.getOperateTime());
//                 esOrderWorkAcceptanceList.add(esOrderWorkAcceptance);
//             });
//             esOrderWork.setOrderWorkAcceptanceList(esOrderWorkAcceptanceList);
//         });
//     }
//
//     /**
//      * 处理订单多次上门
//      *
//      * @param orderOrderVisitMap
//      * @param esOrderWorkMap
//      */
//     private void processOrderVisit(Map<Long, List<OrderVisit>> orderOrderVisitMap, Map<Long, EsOrderWork> esOrderWorkMap) {
//         orderOrderVisitMap.forEach((orderId, orderVisitList) -> {
//             EsOrderWork esOrderWork = esOrderWorkMap.get(orderId);
//             if (esOrderWork == null) {
//                 return;
//             }
//
//             List<EsOrderVisit> esOrderVisitList = Lists.newArrayListWithCapacity(orderVisitList.size());
//             orderVisitList.forEach(orderVisit -> {
//                 EsOrderVisit esOrderVisit = BeanMapper.map(orderVisit, EsOrderVisit.class);
//                 esOrderVisit.setVisitStatusName(OrderVisitStatusConsts.getVisitStatusName(esOrderVisit.getVisitStatus()));
//                 esOrderVisitList.add(esOrderVisit);
//             });
//             esOrderWork.setOrderVisitList(esOrderVisitList);
//         });
//     }
//
//
//
//     /**
//      * 处理照片审核状态
//      *
//      * @param attachmentList
//      * @param extendList
//      * @param esOrderWorkMap
//      * @param esOrderWorkMap
//      */
//     private void processImageReviewStatus(List<OrderAttachment> attachmentList, List<OrderExtend> extendList, Map<Long, EsOrderWork> esOrderWorkMap) {
//         Map<Long, List<OrderAttachment>> attachmentMap = Maps.newHashMap();
//         if (CollectionUtil.isNotNullOrEmpty(attachmentList)) {
//             attachmentMap = attachmentList.stream().collect(Collectors.groupingBy(OrderAttachment::getOrderId));
//         }
//         Map<Long, OrderExtend> extendMap = Maps.newHashMap();
//         if (CollectionUtil.isNotNullOrEmpty(extendList)) {
//             extendMap = extendList.stream().collect(Collectors.toMap(OrderExtend::getExtId, Function.identity(), (e1, e2) -> e1));
//         }
//         for (Long orderId : esOrderWorkMap.keySet()) {
//             EsOrderWork esOrderWork = esOrderWorkMap.get(orderId);
//
//             OrderExtend extend = extendMap.get(orderId);
//             // 附件照
//             List<OrderAttachment> attachments = attachmentMap.get(orderId);
//
//             if (Objects.isNull(extend) && CollectionUtil.isNullOrEmpty(attachments)) {
//                 esOrderWork.setImageStatus(null);
//                 continue;
//             }
//             if (StringUtils.isBlank(extend.getMasterSrc()) && StringUtils.isBlank(extend.getAppliqueSrc()) && CollectionUtil.isNullOrEmpty(attachments)) {
//                 esOrderWork.setImageStatus(null);
//                 continue;
//             }
//
//             Set<Integer> reviewStatusResults = Sets.newHashSet();
//
//             if (Objects.nonNull(extend)) {
//                 // 形象照
//                 String masterImageSrc = extend.getMasterSrc();
//                 Integer masterImageStatus = esOrderWork.getMasterImageStatus();
//
//                 // 待审核
//                 if (StringUtils.isNotBlank(masterImageSrc) && NumberUtil.isNullOrZero(masterImageStatus)) {
//                     reviewStatusResults.add(OrderConsts.IMAGE_REVIEW_STATUS_WAITING);
//                 } else if (Objects.equals(masterImageStatus, GlobalConsts.NO)) {
//                     reviewStatusResults.add(OrderConsts.IMAGE_REVIEW_STATUS_FAIL);
//                 } else if (Objects.equals(masterImageStatus, GlobalConsts.YES)) {
//                     reviewStatusResults.add(OrderConsts.IMAGE_REVIEW_STATUS_SUCCESS);
//                 }
//
//                 // 贴花照
//                 String appliqueSrc = extend.getAppliqueSrc();
//                 Integer appliqueStatus = esOrderWork.getAppliqueStatus();
//                 // 待审核
//                 if (StringUtils.isNotBlank(appliqueSrc) && NumberUtil.isNullOrZero(appliqueStatus)) {
//                     reviewStatusResults.add(OrderConsts.IMAGE_REVIEW_STATUS_WAITING);
//                 } else if (Objects.equals(appliqueStatus, GlobalConsts.NO)) {
//                     reviewStatusResults.add(OrderConsts.IMAGE_REVIEW_STATUS_FAIL);
//                 } else if (Objects.equals(appliqueStatus, GlobalConsts.YES)) {
//                     reviewStatusResults.add(OrderConsts.IMAGE_REVIEW_STATUS_SUCCESS);
//                 }
//             }
//
//             if (CollectionUtil.isNotNullOrEmpty(attachments)) {
//                 for (OrderAttachment attachment : attachments) {
//                     if (!OrderAttachmentTypeEnum.CODE_LIST.contains(attachment.getType())) {
//                         continue;
//                     }
//                     if (Objects.equals(attachment.getNeedReview(), GlobalConsts.NO)) {
//                         reviewStatusResults.add(OrderConsts.IMAGE_REVIEW_STATUS_NO);
//                     } else if (Objects.equals(attachment.getNeedReview(), GlobalConsts.YES)
//                             && NumberUtil.isNullOrZero(attachment.getReviewStatus())) {
//                         reviewStatusResults.add(OrderConsts.IMAGE_REVIEW_STATUS_WAITING);
//                     } else if (Objects.equals(attachment.getNeedReview(), GlobalConsts.YES)
//                             && Objects.equals(attachment.getReviewStatus(), GlobalConsts.NO)) {
//                         reviewStatusResults.add(OrderConsts.IMAGE_REVIEW_STATUS_FAIL);
//                     } else if (Objects.equals(attachment.getNeedReview(), GlobalConsts.YES)
//                             && Objects.equals(attachment.getReviewStatus(), GlobalConsts.YES)) {
//                         reviewStatusResults.add(OrderConsts.IMAGE_REVIEW_STATUS_SUCCESS);
//                     }
//                 }
//             }
//
//             if (reviewStatusResults.contains(OrderConsts.IMAGE_REVIEW_STATUS_FAIL)) {
//                 esOrderWork.setImageStatus(OrderConsts.IMAGE_REVIEW_STATUS_FAIL);
//             } else if (reviewStatusResults.contains(OrderConsts.IMAGE_REVIEW_STATUS_WAITING)) {
//                 esOrderWork.setImageStatus(OrderConsts.IMAGE_REVIEW_STATUS_WAITING);
//             } else {
//                 esOrderWork.setImageStatus(OrderConsts.IMAGE_REVIEW_STATUS_SUCCESS);
//             }
//
//         }
//     }
// }
